Javascript Reference - HTML DOM removeNamedItem() Method








The removeNamedItem() method removes the node with the specified name in a namedNodeMap.

Browser Support

removeNamedItem Yes Yes Yes Yes Yes

Syntax

attr.removeNamedItem(nodename)

Parameters

Parameter Type Description
nodename String Required. The name of the node in the namedNodeMap to remove




Return Value

Type Description
Node object The removed node

Example

The following code shows how to remove the type attribute from an input button.


<!DOCTYPE html>
<html>
<body>
<!-- w w w. ja v  a 2 s .c o  m-->
<input type="button" value="OK">
<button onclick="myFunction()">test</button>

<script>
function myFunction() {
    var btn = document.getElementsByTagName("INPUT")[0];
    btn.attributes.removeNamedItem("type");
}
</script>
</body>
</html>

The code above is rendered as follows: