target event property
Definition and Usage
The target event property returns the element that triggered the event.
The target property gets the element where the event initially occurred, unlike currentTarget propertyThe latter always refers to the element that triggered the event listener.
Instance
Example 1
Get the element that triggered a specific event:
alert(event.target);
Example 2
Use the event.target property and the element.tagName property to find out which element triggered the specified event:
var x = event.target.tagName;
Syntax
event.target
Technical Details
Return Value: | Reference to the object where the event originally occurred. |
---|---|
DOM Version: | DOM Level 2 Events |
Browser Support
The numbers in the table indicate the first browser version that fully supports this property.
Properties | Chrome | IE | Firefox | Safari | Opera |
---|---|---|---|---|---|
target | Support | 9.0 | Support | Support | Support |