Search w3schools.com:

SHARE THIS PAGE

DOM NodeList item() Method

NodeList Object Reference NodeList Object

Example

Return the first child node of an element:

document.body.childNodes.item(0);

Try it yourself »

Definition and Usage

The item() method returns the node at the specified index in a node lists.

Read more about the Node object in our Node object reference.

This syntax:

document.body.childNodes.item(0);

Will produce the same result as this syntax:

document.body.childNodes[0];

Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The item() method is supported in all major browsers.


Syntax

nodelist.item(index)

Parameters

Parameter Type Description
index Number Required. The index of the node you want to return, in the node list

Return Value

Type Description
Node object The node at the specified index

Technical Details

DOM Version Core Level 1


NodeList Object Reference NodeList Object


Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]