currentTarget Event Attribute
Complete Event Object Reference
Definition and Usage
The currentTarget event attribute returns the element whose event listeners
triggered the event.
This is particularly useful during capturing and bubbling.
Syntax
Example
The following example gets the element whose event listeners 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>
|
Try-It-Yourself Demos
Get the element whose event listeners triggered the event
Complete Event Object Reference
|