Is there any way to check if bubble triggered the click?

后端 未结 5 1516
谎友^
谎友^ 2020-12-24 06:07

Clicking on elements in jQuery causes bubble up to body. If we have a click handler binded to body that shows an alert, then clicking on any element will bubble up to body a

5条回答
  •  情歌与酒
    2020-12-24 06:15

    You can check what was clicked with event.target:

    $(something).click(function(e){
        alert(e.target)
    })
    

提交回复
热议问题