HTML DOM item()Method
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
![]()
![]()
![]()
![]()
![]()
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 |
|---|
Other Extensions
Element Object