HTML | DOM removeAttributeNode() Method

The DOM removeAttributeNode() method is used to remove the specified attribute from the current element. It is similar to removeAttribute() method but the difference is that the removeAttribute method is used to remove the attribute with the specified name, but on the other hand removeAttributeNode removes the specified attribute object.

Syntax:

element.removeAttributeNode(name)

Where name is the attribute node to be removed. It is the required field.



Return Value: It returns the attribute node to be removed.

Example:

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
  
<head>
    <title>HTML DOM removeAttributeNode Method</title>
    <style>
        .gfg {
            color: green;
        }
    </style>
</head>
  
<body style="text-align: center;">
    <h1 style="color:green;">
            GeeksforGeeks
        </h1>
  
    <h2>
            DOM removeAttributeNode Method
        </h2>
  
    <p id="p" class="gfg">
      A computer science portal for geeks.
    </p>
  
    <button onclick="Geeks()">Click Here!</button>
  
    <script>
        function Geeks() {
            var d = document.getElementById("p");
            var color = d.getAttributeNode("class");
            
            // Removing attribute node.
            d.removeAttributeNode(color);
        }
    </script>
</body>
  
</html>

chevron_right


Output:

Before click on the button:
removeAttributeNode

After click on the button:
removeAttributeNode

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

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


My Personal Notes arrow_drop_up


If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.