Get the tagName of an element:
The result of x will be:
More "Try it Yourself" examples below.
The tagName property returns the tag name of the element.
In HTML, the returned value of the tagName property is always in UPPERCASE.
This property is read-only.
Tip: You can also use the nodeName property to return the tag name of an element. The difference is that nodeName also returns attribute nodes, text nodes, comment nodes.
Property | |||||
---|---|---|---|---|---|
tagName | Yes | Yes | Yes | Yes | Yes |
Return Value: | A String, representing the tag name of the element in uppercase |
---|---|
DOM Version | Core Level 1 Element Object |
Using the tagName property together with the event.target property to find out which element triggered a specified event:
HTML DOM reference: node.nodeName Property