Get the element that triggered the event:
const element = event.currentTarget;
Try it Yourself »
Get the name of the element that triggered the event:
let text = event.currentTarget.tagName;
Try it Yourself »
More examples below.
The currentTarget
property returns the element whose event listener triggered the event.
The currentTarget
property is read-only.
The currentTarget
property is useful during capturing and bubbling.
The target
property refers to the element whose event listener triggered the event, opposed to the target
property, which returns the element that triggered the event.
event.currentTarget
Return Value: | An Object. The object whose event listeners triggered the event. |
---|---|
DOM Version: | DOM Level 2 Events. |
Get the name of the element where the event occurred:
let text = event.target.tagName;
Try it Yourself »
event.currentTarget
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 |
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!