HTML | DOM target Event Property
The target event property in HTML DOM is used to return the element that triggered the event.
Syntax:
event.target
Return Value: This property returns the reference of the object on which the event originally occurred.
Below example illustrates the target Event Property in HTML DOM:
Example:
<!DOCTYPE html> <html> <head> <title> HTML DOM target Event Property </title> <style> body { text-align:center; } h1 { color:green; } </style> </head> <body onclick="myGeeks(event)"> <h1>GeeksforGeeks</h1> <h2>HTML DOM target Event Property</h2> <p>Click on the elements to get the triggered element</p> <button>Click Here</button> <p id = "GFG"></p> <script> function myGeeks(event) { var x = event.target; document.getElementById("GFG").innerHTML = "Triggered element: " + x.tagName; } </script> </body> </html> |
chevron_right
filter_none
Output:

Supported Browsers: The browsers supported by HTML DOM target Event Property are listed below:
- Google Chrome
- Internet Explorer 9.0
- Firefox
- Safari
- Opera
Recommended Posts:
- HTML | DOM Base target Property
- HTML | DOM Form target Property
- HTML | DOM Anchor target Property
- HTML | DOM Area target Property
- HTML | cancelable Event Property
- HTML | currentTarget Event Property
- HTML | defaultPrevented Event Property
- HTML | DOM type Event Property
- HTML | returnValue Event Property
- HTML | view Event Property
- HTML | DOM timeStamp Event Property
- HTML | DOM cancelable Event Property
- HTML | isTrusted Event Property
- HTML | bubbles Event Property
- HTML | <a> target Attribute
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



