Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

HTML DOM getNamedItem() method

HTML DOM getNamedItem() method

Attribute Object Reference Attribute object

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

Internet ExplorerFirefoxOperaGoogle ChromeSafari

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 Reference Attribute object