Skip to content
Related Articles

Related Articles

Improve Article

HTML | DOM getNamedItem() Method

  • Difficulty Level : Basic
  • Last Updated : 23 Jul, 2019

The DOM getNamedItem() method in HTML is used to return the attribute node from the NamedNodeMap object.


namednodemap.getNamedItem( nodename )

Parameter’s Value: This method contains single parameter nodename which is mandatory. The nodename is retured from NamedNodeMap object.


<!DOCTYPE html>
            DOM getNamedItem() Method
            /* main function */
            function MyGeeks() {
                var ele = document.getElementsByTagName("button")[0];
                var item = ele.attributes.getNamedItem("onclick").value; 
                document.getElementById("geeks").innerHTML = item;
    <body style = "text-align:center">
        <h2>DOM getNamedItem() Method</h2>
            Click on the button to know the
            value of onclick attribute
        <button onclick = "MyGeeks()">
            Click Here!
        <p id="geeks"></p>

Before click on the button:

After click on the button:

Supported Browsers: The browser supported by DOM getNamedItem() Method are listed below:

  • Google Chrome
  • Internet Explorer 9.0
  • Firefox
  • Opera
  • Safari

Attention reader! Don’t stop learning now. Get hold of all the important Comcompetitivepetitve Programming concepts with the Web Design for Beginners | HTML  course.

My Personal Notes arrow_drop_up
Recommended Articles
Page :