次の2つの方法に違いはありますか?#1 は #2 より速いですか?
#1
$('#selector').on('click',function(){
$(this)...
// do stuff with clicked element
})
と
#2
$('#selector').on('click',function(e){
$(e.currentTarget)....
// do stuff with clicked element
})
次の2つの方法に違いはありますか?#1 は #2 より速いですか?
#1
$('#selector').on('click',function(){
$(this)...
// do stuff with clicked element
})
と
#2
$('#selector').on('click',function(e){
$(e.currentTarget)....
// do stuff with clicked element
})
「this」の方が入力しやすいようですが、ほとんどの場合は同等のようです
http://api.jquery.com/event.currentTarget/によると
event.currentTarget
このプロパティは通常、関数の と等しくなり
this
ます。jQuery.proxyまたは別の形式のスコープ操作 を使用している
this
場合は、提供したコンテキストと等しくなります。event.currentTarget