Check if click occured inside or outside of modal window

This question already has an answer here:

  • How do I detect a click outside an element? 76 answers

  • 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.

    链接地址: http://www.djcxy.com/p/14718.html

    上一篇: 如何使用xPath添加jQuery点击事件?

    下一篇: 检查点击模式窗口内部或外部是否发生