Event Capturing, Event Bubbling and jQuery.on()

前端 未结 2 750
广开言路
广开言路 2021-02-07 14:57

I have an interesting question about event capturing, bubbling and jQuery.on().

I have recently learned more about the dif

2条回答
  •  暗喜
    暗喜 (楼主)
    2021-02-07 15:36

    You can use e.target to get the exact element that was clicked

      $('.parent').on('click', function(e){
        if(e.target.classList.contains('child'))
          // do something
        }
      })
    

提交回复
热议问题