Is event.currentTarget always equal to $(this) in jQuery?

前端 未结 3 812
失恋的感觉
失恋的感觉 2021-02-13 19:29

Is this phrase always true?

$(\"p\").click(function(event) {
  alert( event.currentTarget === this ); 
});  

Is one method preferred over the o

3条回答
  •  清歌不尽
    2021-02-13 20:07

    Part of your answer is above. I hope its clear enough.

    No console.log(this) and console.log($j(this)) will not give you the same result. $(this) converts this to a jQuery Object and hence you can call .css like methods which can be called on jQuery objects($(this)) and not the HTML elements which will be this.

提交回复
热议问题