Search w3schools.com:

SHARE THIS PAGE

DOM Node nodeType Property

Node Object Reference Node Object

Example

Get the node type of the body element:

document.body.nodeType;

The result will be:

1

Try it yourself »

Definition and Usage

The nodeType property returns the node type, as a number, of the specified node.

If the node is an element node, the nodeType property will return 1.

If the node is an attribute node, the nodeType property will return 2.

Read more about node types in our Node Types reference.


Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The nodeType property is supported in all major browsers.


Syntax

node.nodeType

Technical Details

Return Value: A String, representing the node type 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]