HTML DOM item()Method

属性对象参考手册Attr Object

Examples

Return the first attribute name of the button element:

document.getElementsByTagName("BUTTON")[0].attributes.item(0).nodeName;

Output:

onclick

Try it Yourself »

Definition and Usage

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

Syntax:

document.getElementsByTagName("BUTTON")[0].attributes.item(0);

Alternative syntax:

document.getElementsByTagName("BUTTON")[0].attributes[0];

Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the item() method


Syntax

namednodemap.item(index)

Parameters

Parameter Type Description
index Number Required. The index of the specified node in the NodeList.

Return Value

Type Description
Node object The node at the specified index

Technical Details

DOM Version Core Level 1


属性对象参考手册Attr Object

Other Extensions