Jaa


currentTarget property

Gets the event target that is currently being processed.

 

Syntax

HRESULT value = object.get_currentTarget(IEventTarget** p);

Property values

Type: Object

The current target of the event.

Standards information

Remarks

The IDOMEvent::target property returns the element that originally received an event. However, the IDOMEvent::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 IDOMEvent::currentTarget and IDOMEvent::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 IHTMLElement2::attachEvent, you cannot access the current event target in the event handler.

See also

IDOMEvent::eventPhase