Get the tagName of the "demo" element:
let name = document.getElementById("demo").tagName;
Try it Yourself »
Find which element triggered an event:
const element = event.target;
let name = element.tagName;
Try it Yourself »
The tagName
property returns the tag name of an element.
The tagName
property returns the tag name in UPPERCASE.
The tagName
property is read-only.
The nodeName
property also returns the tag name of an element.
The nodeName
can also return the tag name of attribute nodes, text nodes, and comment nodes.
element.tagName
Type | Description |
String | The tag name of the element (in uppercase). |
element.tagName
is a DOM Level 1 (1998) feature.
It is fully supported in all browsers:
Chrome | Edge | Firefox | Safari | Opera | IE |
Yes | Yes | Yes | Yes | Yes | 9-11 |
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!