HTML DOM item () method
Examples
Back button element of the first attribute name:
document.getElementsByTagName("BUTTON")[0].attributes.item(0).nodeName;
Output:
onclick
try it"
Definition and Usage
item () method returns the list of nodes in the node at the specified index number.
grammar:
document.getElementsByTagName("BUTTON")[0].attributes.item(0);
Another writing:
document.getElementsByTagName("BUTTON")[0].attributes[0];
Browser Support
All major browsers support item () method
grammar
namednodemap.item( index )
parameter
参数 | 类型 | 描述 |
---|---|---|
index | Number | 必须。节点列表中指定的节点索引号。 |
return value
类型 | 描述 |
---|---|
节点对象 | 指定索引的节点 |
technical details
DOM version | Core Level 1 |
---|