Search w3schools.com:

SHARE THIS PAGE

DOM Node nodeName Property

Node Object Reference Node Object

Example

Get the node name of the body element:

document.body.nodeName;

The result will be:

BODY

Try it yourself »

Definition and Usage

The nodeName property returns the name of the specified node.

If the node is an element node, the nodeName property will return the tagname.

If the node is an attribute node, the nodeName property will return the name of the attribute.

For other node types, the nodeName property will return different names for different node types.

Read more about node types in our Node Types reference.


Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The nodeName property is supported in all major browsers.


Syntax

node.nodeName

Technical Details

Return Value: A String, representing the name of the node
DOM Version Core Level 1


Node Object Reference Node Object

Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]