How to trigger other functions when clicking Lightbox close button?

Hello :wave:

Does anyone know how to run some custom code after clicking the Lightbox close button?

My code is $(document).ready(function() { $(".w-lightbox-control.w-lightbox-close").click(function(){ console.log("the close button clicked!"); }); });

It won’t work actually…
But if I copy the code and just paste that into the Console in the DevTools of Chrome.
It will work!

I’m not really familiar with javascript but I guess I need to run this code in the very end, right?
Just don’t know how to do, hope there’s some one can help.

Many thanks!

Here is my site Read-Only: [LINK][1]