Compare 'e.target' to a jQuery object

后端 未结 4 1470
情书的邮戳
情书的邮戳 2021-02-06 22:00

What I want to do:

( clickedObject === someDiv ) //returns true or false

What I tried

( $(e.target) === $(\'.selector\') ); //r         


        
4条回答
  •  故里飘歌
    2021-02-06 22:52

    If you want to match the element that the event is attached to you can use $(this), or if you want to find which element triggered the event use $(event.target).

    Below is an example of both of these.

    http://jsfiddle.net/Phunky/TbJef/

    Unless you're using event delegation these will be the same though and if there the same element.

提交回复
热议问题