HTML tutorial
CSS3 tutorial
Bootstrap tutorial
JavaScript tutorial
JQuery tutorial
AngularJS tutorial
React tutorial
NodeJS tutorial
PHP tutorial
Python tutorial
Python3 tutorial
Django tutorial
Linux tutorial
Docker tutorial
Ruby tutorial
Java tutorial
C tutorial
C ++ tutorial
Perl tutorial
JSP tutorial
Lua tutorial
Scala tutorial
Go tutorial
ASP.NET tutorial
C # tutorial
Get the element that triggered a specific event
The target event property returns the element that triggered the event.
The target property gets the element on which the event originally occurred, opposed to the currentTarget property, which always refers to the element whose event listener triggered the event.
The numbers in the table specify the first browser version that fully supports the property.
Property | |||||
---|---|---|---|---|---|
target | Yes | 9.0 | Yes | Yes | Yes |
Return Value: | A reference to the object on which the event originally occured |
---|---|
DOM Version: | DOM Level 2 Events |
Using the event.target property together with the element.tagName property to find out which element triggered a specified event:
var x = event.target.tagName;