Attribute removeNamedItem() Method - Javascript DOM

Javascript examples for DOM:Attribute

Description

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

Parameter Values

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

Return Value:

A Node object, representing the removed attribute node

The following code shows how to Remove the type attribute from an input button:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<input type="button" value="OK">

<button onclick="myFunction()">Test</button>

<script>
function myFunction() {//from  w w w. ja  v a 2  s.co m
    var btn = document.getElementsByTagName("INPUT")[0];
    btn.attributes.removeNamedItem("type");
}
</script>

</body>
</html>

Related Tutorials