diff --git a/entries/event.currentTarget.xml b/entries/event.currentTarget.xml index 5a3f8b0a..c1a0418a 100644 --- a/entries/event.currentTarget.xml +++ b/entries/event.currentTarget.xml @@ -2,16 +2,225 @@ 1.3 - The current DOM element within the event bubbling phase. -

This property will typically be equal to the this of the function.

-

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

-
- - Alert that currentTarget matches the `this` keyword. - - - - - \ No newline at end of file + A DOM element: event.target, or an ancestor if the event is bubbling. + + + +

This property will typically be equal to the this of the function.

+ +

If jQuery.proxy or another form of scope manipulation is used, this will be equal to whatever context was provided, not event.currentTarget.

+ + +

+ The W3C DOM Event interface includes a .currentTarget property ("standard .currentTarget"), that some browsers implement in their native event objects. jQuery's event.currentTarget may or may not contain the same value as the standard .currentTarget: it depends whether the event listener registration was direct or delegated. event.delegateTarget (available from jQuery 1.7) will contain the value of the standard .currentTarget. +

+ +

+ Consider this markup: +

+ +
+ +

+ When event registration is direct, $( "p" ).on( 'click', handler ), then event.currentTarget will have the same value as the standard .currentTarget: the current DOM element within the event bubbling phase. This call to .on() would result in event.currentTarget being set to the p. +

+ +

+ When event registration is delegated, $( "p" ).on( 'click', "span", handler ), then event.currentTarget will be set to the DOM element that matches the selector (in this case, "span"). In this scenario jQuery sets event.currentTarget as if the event were registered directly on the element that matches the selector. This call to .on() would result in event.currentTarget being set to the span. +

+ +

+ In both of the preceding examples, the event listener is actually registered on the p and the event is handled when bubbling reaches the p. The standard .currentTarget property would be set to the p. +

+ +

+ If event registration is delegated, in jQuery 1.7+ the value that the standard .currentTarget would have can be accessed as event.delegateTarget. In browsers that implement the standard .currentTarget in their native event object, it can be accessed as event.originalEvent.currentTarget. +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + Example values of event target properties for direct and delegated events. + +
+ Direct event registration +
+ Registration code + + $( "p" ).on( 'click', handler ) +
+ Property + + Element +
+ event.currentTarget + + p +
+ event.delegateTarget + + p +
+ event.originalEvent.currentTarget + + p +
+ Delegated event registration +
+ Registration code + + $( "p" ).on( 'click', "span", handler ) +
+ Property + + Element +
+ event.currentTarget + + span +
+ event.delegateTarget + + p +
+ event.originalEvent.currentTarget + + p +
+ +
+ + + Alert that currentTarget matches the `this` keyword. + + + + + + + +