XML DOM currentTarget event attribute
Definition and usage
The currentTarget event attribute returns the node that triggered the listener, that is, the element, document, or window that is currently handling the event.
This property is very useful in the capture and bubble phases, because it is different from the target property at these two nodes.
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.