How to prevent a click() event through a child div to a parent div in jQuery?

前端 未结 3 1709
谎友^
谎友^ 2021-01-01 09:06

Situation:

+ OPEN
3条回答
  •  天涯浪人
    2021-01-01 09:41

    You need to stop the event from propagating up the DOM tree:

    $('.closeBtn').click(function (evt) {
        evt.stopPropagation();
    
        // Your code here
    });
    

提交回复
热议问题