HTML DOM getNamedItem()Method
Examples
Returns the value of the button element's onclick attribute:
var btn=document.getElementsByTagName("BUTTON")[0];
btn.attributes.getNamedItem("onclick").textContent;
btn.attributes.getNamedItem("onclick").textContent;
Output:
myfunction()
Try it Yourself »
Definition and Usage
The getNamedItem() method returns the value of the specified attribute name from 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 name of the node you want to return from the node list. |
Return Value
| Type | Description |
|---|---|
| Node object | The node with the specified name. |
Technical Details
| DOM Version | Core Level 1 |
|---|
Other Extensions
Attribute Object