X
HOME HTML5 CSS3 JAVASCRIPT SQL PHP5 JQUERY ANGULAR BOOTSTRAP3 XML MORE...
REFERENCES | EXAMPLES | FORUM | ABOUT

target Event Property

Event Object Reference Event Object

Example

Get the element that triggered a specific event:

alert(event.target);

Try it yourself »

More "Try it Yourself" examples below.


Definition and Usage

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.


Browser Support

The numbers in the table specify the first browser version that fully supports the property.

Property
target Yes 9.0 Yes Yes Yes


Syntax

event.target

Technical Details

Return Value: A reference to the object on which the event originally occured
DOM Version: DOM Level 2 Events


Examples

More Examples

Example

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;

Try it yourself »


Event Object Reference Event Object

Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

WEB HOSTING

UK Reseller Hosting

WEB BUILDING

Download XML Editor FREE Website BUILDER Free HTML5 Templates

SHARE THIS PAGE

facebook