sup*_*ova 17 jquery javascript-events
以下两种方法有什么区别吗?比#2快#1?
#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
})
Run Code Online (Sandbox Code Playgroud)
use*_*347 15
似乎在大多数情况下它们是等效的,尽管"这个"似乎更容易输入
根据http://api.jquery.com/event.currentTarget/
event.currentTarget此属性通常等于
this函数的属性.如果您使用的是jQuery.proxy或其他形式的范围操作,
this则将等于您提供的任何上下文,而不是event.currentTarget
| 归档时间: |
|
| 查看次数: |
14518 次 |
| 最近记录: |