The removeNamedItem()
method removes the node with
the specified name in a namedNodeMap.
removeNamedItem |
Yes | Yes | Yes | Yes | Yes |
attr.removeNamedItem(nodename)
Parameter | Type | Description |
---|---|---|
nodename | String | Required. The name of the node in the namedNodeMap to remove |
Type | Description |
---|---|
Node object | The removed node |
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: