Skip to content
Related Articles

Related Articles

HTML | DOM getAttributeNode() Method

View Discussion
Improve Article
Save Article
  • Last Updated : 25 Jul, 2019
View Discussion
Improve Article
Save Article

The getAttributeNode() method in HTML DOM is used to return the attribute node with the specified name of an element, as an attribute object. This function is similar to getAttribute() method but the only difference is that the getAttribute() method returns the value of an attribute node, not any attribute object.


element.getAttributeNode( attribute_name )

Parameters: This method accepts single parameter attribute_name which is mandatory. This parameter is used to hold the name of attribute.

Return Value: This method returns an attribute object which represents the attribute node.

Example: This example contains two heading elements and the task is to display the value of attribute node of the second heading element.

<!DOCTYPE html>
            HTML DOM getAttributeNode() Method
        <!--script to display the value of
            class attribute -->
            function Geeks() {
                var element_name =
                var attribute = 
                        = attribute;
        <h1 class = "Frst_heading">
        <h2 class = "Second_heading">
            DOM getAttributeNode() Method
            Click on the button to display
            the value of attribute node
        <button onclick = "Geeks()">
            Click Here!
        <p id = "result"></p>

Before click on the button:

After click on the button:

Supported Browsers: The browser supported by DOM getAttributeNode() method are listed below:

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

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!