Event Capturing, Event Bubbling and jQuery.on()

前端 未结 2 723
广开言路
广开言路 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't. jQuery events works with event bubbling it doesn't support capturing.

    Also see

    • Why does jQuery event model does not support event Capture and just supports event bubbling
    0 讨论(0)
  • 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
        }
      })
    
    0 讨论(0)
提交回复
热议问题