Search w3schools.com:

SHARE THIS PAGE

DOM NamedNodeMap getNamedItem() Method

NamedNodeMap Object Reference NamedNodeMap Object

Example

Return the value of the onclick attribute of a button element:

var btn=document.getElementsByTagName("BUTTON")[0]; btn.attributes.getNamedItem("onclick").textContent;

The result could be:

myFunction()

Try it yourself »

Definition and Usage

The getNamedItem() method returns the node with the specified name in a namedNodeMap, as a Node object.

Read more about the Node object in our Node object reference.


Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The getNamedItem() method is supported in all major browsers.

Note: Internet Explorer 8 and earlier does not support this method.


Syntax

namednodemap.getNamedItem(name)

Parameters

Parameter Type Description
nodename String Required. The name of the node in the namedNodeMap you want to return

Return Value

Type Description
Node object The node with the specified name

Technical Details

DOM Version Core Level 1


NamedNodeMap Object Reference NamedNodeMap Object


Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]