Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

HTML DOM nodeName Property

HTML DOM nodeName Property

Element Object Reference Element object

Example

Get the node name of the body element:

document.body.nodeName;

Output result:

BODY

Try it »


Definition and Usage

The nodeName property returns the name based on the type of the node.

If the node is an element node, the nodeName property returns the tag name.

If the node is an attribute node, the nodeName property returns the attribute name.

For other node types, the nodeName property returns different node names depending on the node type.


Browser support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the nodeName property


Syntax

node

.nodeName

Technical Details

Return Value: String, representing the name of the node.
DOM version Core Level 1 Node Object

Element Object Reference Element object