$(e.currentTarget)和$(this)之间有区别吗? [英] Is there a difference between $(e.currentTarget) and $(this)?
本文介绍了$(e.currentTarget)和$(this)之间有区别吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
以下两种方法有什么区别吗?比#2快#1?
is there any difference between the following two methods? is #1 faster than #2 ?
#1
$('#selector').on('click',function(){
$(this)...
// do stuff with clicked element
})
and
#2
$('#selector').on('click',function(e){
$(e.currentTarget)....
// do stuff with clicked element
})
推荐答案
Seems like they are equivalent in most cases, though "this" seems easier to type
rel =noreferrer> http://api.jquery.com/event.currentTarget/
according to http://api.jquery.com/event.currentTarget/
event.currentTarget
此属性通常等于此
的函数。
This property will typically be equal to the this
of the function.
如果您使用的是 jQuery。代理或其他形式的范围操纵,
此
将等于w你提供的hatever上下文,而不是
event.currentTarget
If you are using jQuery.proxy or another form of scope manipulation,
this
will be equal to whatever context you have provided, not
event.currentTarget
这篇关于$(e.currentTarget)和$(this)之间有区别吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文