JavaScript event.currentTarget against this

Is there any difference between event.currentTargetand this? What about performance?

+5
source share
2 answers

The event attribute currentTargetreturns the element whose event listeners raised the event. This is especially useful for trapping and blistering.

You can also use a keyword this, but when using the Microsoft event logging model, the keyword thisdoes not reference an HTML element.

For more information, see the following link: http://www.quirksmode.org/js/events_order.html

* Microsoft mode issues * l

Microsoft, HTML. currentTarget Microsoft ,

element1.attachEvent('onclick',doSomething)
element2.attachEvent('onclick',doSomething)

, HTML- . Microsoft, , IE/Win.

: ,

+2

jQuery , event.currentTarget this ( jQuery.proxy ):

.

jQuery.proxy , this , , event.currentTarget

https://api.jquery.com/event.currentTarget/

0

All Articles