0

I am catching click on website and closing modal window.

But how to actually check if click occured inside or outside of modal window?

    $(document).click(callself(this, function (inst, event) {
        var modalElement = $(selector);
        if (modalElement.css("display") == "block") {
            this.closeButtonClicked();
        }
    }));
Szymon Toda
  • 4,454
  • 11
  • 43
  • 62

1 Answers1

2

lets say your modal window id is modal.

with jQuery:

$(function(){
    $(document).click(function(){
        console.log('document is clicked');
    });

    $('#modal').click(function(e){
        e.preventDefault();
        e.stopPropagation();
        console.log('modal is clicked');
    });
});

hope that helps.

geevee
  • 5,411
  • 5
  • 30
  • 48