HTML DOM item()Method

元素对象参考手册Element Object

Example

Returns 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 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

Parameter Type Description
index Number Required. The index 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

Other Extensions