Javascript DOM HTML NamedNodeMap removeNamedItem() Method

Introduction

Remove the type attribute from an input button.

Click the button to remove the type attribute of the input element above.

When removing the type attribute of an input element, the element will be of type text, which is the default value.

View in separate window

<!DOCTYPE html>
<html>
<body>

<input type="button" value="OK">
<button onclick="myFunction()">Test</button>
<script>
function myFunction() {// w  ww  .  j  a v  a 2s.c o m
  var btn = document.getElementsByTagName("INPUT")[0];
  btn.attributes.removeNamedItem("type");
}
</script>

</body>
</html>

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

removeNamedItem(nodename); 

Parameter Values

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

The removeNamedItem() method returns a Node object representing the removed attribute node.




PreviousNext

Related