XML DOM currentTarget Event Property
Definition and Usage
The currentTarget event property returns the node that triggered the listener, i.e., the element, document, or window that is currently handling the event.
This property is very useful in the capture and bubble phases, because at these two nodes, it is different from the target property.
Syntax
event.currentTarget
Example
The following example shows which element's listener triggered the event:
<html>
<head>
<script type="text/javascript">
function getEventTrigger(event)
{
x=event.currentTarget
;
alert("The id of the triggered element: ")
+ x.id);
}
</script>
</head>
<body >
<p id="p1" onmousedown="getEventTrigger(event)">
Click on this paragraph. An alert box will
Show which element triggered the event.</p>
</body>
</html>
TIY
- currenttarget event
- Get the element that triggered the listener event.