[removed] Find out which element was clicked without attaching any eventlistener to it?

后端 未结 3 1805
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-05 02:51

I am confused on finding an approach to resolve this issue. Consider below html


  
相关标签:
3条回答
  • 2021-01-05 02:58

    Yes, you can check the event's target property which will indicate the element that was clicked. You can read more about event properties here.

    0 讨论(0)
  • 2021-01-05 03:03
    $("#parent").click(function(e){
       console.log(e.target);
    });
    

    Demo: http://jsfiddle.net/4bC6K/

    0 讨论(0)
  • 2021-01-05 03:14

    Yes, use target:

    function(e){
        // e.target is the clicked div
    }
    

    Example: http://jsfiddle.net/Paulpro/AfA4t/

    0 讨论(0)
提交回复
热议问题