Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.
This topic has not yet been rated - Rate this topic

currentTarget property

Gets the event target that is currently being processed.

Document Object Model (DOM) Level 3 Events Specification, Section 4.1Internet Explorer 9

Syntax

JavaScript

p = object.currentTarget

Property values

Type: Object

The current target of the event.

Standards information

Remarks

The target property returns the element that originally received an event. However, the currentTarget property returns the element that the event handlers are being processed for during the capturing and bubbling phases. At event phase AT_TARGET, the currentTarget and target objects are the same object.

In Windows Internet Explorer 8 and earlier versions, the event object does not provide access to the current event target. For the equivalent functionality, specify the this keyword as an argument to the event handler, as the following code example shows.


<button id="target" onclick="myHandler(event, this);">...</button>
function myHandler(evt, elem) {
    alert(elem.id);
} 

Alternatively, if the event handler is set with an event property, the current target is set as the this keyword when the event handler is invoked, as the following code example shows.


document.getElementById('target').onclick = myHandler;
function myHandler(evt) {
    alert(this.id);
} 

If you use attachEvent, you cannot access the current event target in the event handler.

See also

BeforeUnloadEvent
CompositionEvent
CustomEvent
DragEvent
Event
FocusEvent
KeyboardEvent
MessageEvent
MouseEvent
MouseWheelEvent
MSSiteModeEvent
MutationEvent
StorageEvent
SVGZoomEvent
TextEvent
UIEvent
eventPhase

 

 

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.