HTML DOM removeNamedItem() Method

Last Updated : 4 Aug, 2026

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() contains only one parameter nodename that is described below. 
  • nodename: This method accepts a single parameter nodename which is mandatory. It refers to the name of the node in the namednode which needs to remove.

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

Example: In this example, we will use removeNamedItem() method

HTML
<!--Driver Code Starts-->
<!DOCTYPE html>
<html>
<head>
    <title>
        DOM removeNamedItem() Method
    </title>
</head>

<body style="text-align: center;">
    <h1 style="color: green">
        GeeksforGeeks
    </h1>
    <h2>
        DOM removeNamedItem() Method
    </h2>
<!--Driver Code Ends-->

    <input type="button" value="Change It!">
    <!-- removeNamedItem() method used here -->
    <button onclick="myFunction()">
        Click Here!
    </button>
      <script>
        function myFunction() {
            let button =
                document.getElementsByTagName("INPUT")[0];
            button.attributes.removeNamedItem("type");
        }
    </script>

<!--Driver Code Starts-->
</body>

</html>
<!--Driver Code Ends-->
Comment