Skip to content
Related Articles
Open in App
Not now

Related Articles

HTML | DOM removeNamedItem() Method

Improve Article
Save Article
Like Article
  • Last Updated : 08 Jul, 2022
Improve Article
Save Article
Like Article

The removeNamedItem() method in HTML is used to remove the node with the specified name in a namednode object.
Syntax: 
 

namednode.removeNamedItem( nodename )

Parameter: The removeNamedItem() contain only one parameter nodename that is described below. 
 

  • nodename: This method accepts single parameter nodename which is mandatory. It refers to the name of the node in the namednode which need to remove.

Return Value: It returns a Node object that, representing the removed attribute node

Example: 
 

html




<!DOCTYPE html>
<html>
    <head>
        <title>
            DOM removeNamedItem() Method
        </title>
        <script>
            function myFunction() {
                var button =
                    document.getElementsByTagName("INPUT")[0];
                button.attributes.removeNamedItem("type");
            }
        </script>
    </head>
     
    <body style = "text-align: center;">
         
        <h1 style = "color: green">
            GeeksforGeeks
        </h1>
         
        <h2>
            DOM removeNamedItem() Method
        </h2>
         
        <input type="button" value="Change It!">
         
        <!-- removeNamedItem() method used here -->
        <button onclick="myFunction()">
            Click Here!
        </button>
    </body>
</html>                   

Output: 
Before click on the Click Here Button: 
 

removeNamedItem

After click on the Click Here Button: 
 

removeNamedItem2

Note: When we are removing the type attribute of an input element, then the element will be of type text, which is the default value.
Supported Browsers: The browser supported by removeNamedItem() method are listed below: 
 

  • Google Chrome 1
  • Edge 12
  • Internet Explorer 6
  • Firefox 1
  • Opera 12.1
  • Safari 1

 


My Personal Notes arrow_drop_up
Like Article
Save Article
Related Articles

Start Your Coding Journey Now!