target Event Property
Examples
Get the element where the event occurred:
const element = event.target;
Try it Yourself »
Get the name of the element where the event occurred:
let text = event.target.tagName;
Try it Yourself »
More examples below.
Description
The target
property returns the element where the event occured.
The target
property is read-only.
The target
property returns the element on which the event occurred,
opposed to the currentTarget
property,
which returns the element whose event listener triggered the event.
See Also:
Syntax
event.target
Technical Details
Return Value: | An Object. The object where the event originally occured. |
---|---|
DOM Version: | DOM Level 2 Events. |
More examples
Example
Get the element that triggered the event:
const element = event.currentTarget;
Try it Yourself »
Example
Get the name of the element that triggered the event:
let text = event.currentTarget.tagName;
Try it Yourself »
Browser Support
event.target
is a DOM Level 2 (2001) feature.
It is fully supported in all browsers:
Chrome | Edge | Firefox | Safari | Opera | IE |
Yes | Yes | Yes | Yes | Yes | 9-11 |
Copyright 1999-2023 by Refsnes Data. All Rights Reserved.