HTML DOM getNamedItem() method
Example
Return the value of the onclick attribute of the button element:
var btn=document.getElementsByTagName("BUTTON")[0];
btn.attributes.getNamedItem("onclick").textContent;
Output result:
myfunction()
Try it »
Definition and Usage
The getNamedItem() method returns the value of the specified attribute name in the node list.
Browser support





All major browsers support the getNamedItem() method
Note: Internet Explorer 8 and earlier IE versions do not support this method.
Syntax
namednodemap
.getNamedItem(
name
)
Parameters
| Parameters | Type | Description |
|---|---|---|
| nodename | String | Required. The node name you want to return in the node list. |
Return Value
| Type | Description |
|---|---|
| Node object | The node with the specified name. |
Technical Details
| DOM version | Core Level 1 |
|---|
Attribute object