XML DOM target event property
Definition and usage
The target event property can return the target node of the event (the node that triggered the event), such as the element that generates the event, the document, or the window.
Syntax
event.target
Example
The following example shows how to get the element that triggered the event:
<html>
<head>
<script type="text/javascript">
function getEventTrigger(event)
{
x=event.target
;
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
- Target event
- Get the element that triggered the event (IE browser does not support).