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

HTML DOM item() method

HTML DOM item() method

Element Object Reference Element object

Example

Return the first child node of an element:

document.body.childNodes.item(0);

Try it »


Definition and Usage

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

Syntax:

document.body.childNodes.item(0);

Another syntax:

document.body.childNodes[0];


Browser support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the item() method


Syntax

nodelist

.item(

index

)

Parameters

Parameters Type Description
index Number Required. The index value of the node you want to return from the node list.

Return Value

Type Description
Node object The node at the specified index

Technical Details

DOM version Core Level 1 Nodelist Object

Element Object Reference Element object