jQuery not recognising click on modal close link ( href="#' )

188 Views Asked by At

I have modal close link which closes the open modal;

.clicker
   a.icon.icon-close.pull-left.closeover.white href="#mymodal"

and I have the following javascript on the page

$('.clicker').on( "click", function(e) {
      e.preventDefault();
      console.log('modal closed');
    });

I want to do something before (or directly after) closing the modal but the code doesn't work, what am I doing wrong?

I'm using ratchet

1

There are 1 best solutions below

2
On

The element is dynamically added in the dom, so event has to be delegated to the static parent:

$(document.body).on( "click", '.clicker', function(e) {

and this could be the issue:

enter image description here