XML DOM target event property

Definition and Usage

The target event property returns 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
ການຄົ້ນພົບປະກອບສະເພາະທີ່ກະຕຸ້ນເຫດການ (IE Browser ບໍ່ສາມາດສະໜັບສະໜູນໄດ້).