X
HOME HTML CSS JAVASCRIPT SQL PHP JQUERY XML ASP.NET MORE...
REFERENCES | EXAMPLES | FORUM | ABOUT

HTML DOM getNamedItem() Method

Attribute Object Reference Attribute 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 attribute node with the specified name from a namedNodeMap.


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


Attribute Object Reference Attribute Object


Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

WEB BUILDING

Download XML Editor FREE Website BUILDER Free HTML5 Templates FREE Website Templates Free HTML Templates

SHARE THIS PAGE

facebook