Removes an attribute with a given name.
Method of dom/NamedNodeMapdom/NamedNodeMap
Syntaxvar attribute = attributes.removeNamedItem();
Parameters name
The name of an attribute to remove.
Return ValueReturns an object of type DOM NodeDOM Node
The removed attribute.
ExamplesThe following example shows how to use this method to remove an attribute from an element.
<!doctype html>
<html>
<head>
<title>removeNamedItem example</title>
<script>
function removeAttrib() {
var attributes = document.getElementById("ex").attributes;
attributes.removeNamedItem("title");
}
</script>
</head>
<body>
<div onclick="removeAttrib();" id="ex" title="This is a tooltip">
Click this DIV and the tooltip will be deactivated.</div>
</body>
</html>
Notes
An attribute that is removed with this method reverts to the default value of the attribute when applicable. This method returns a script error if the user attempts to remove a non-existent attribute node. removeNamedItem was introduced in Microsoft Internet Explorer 6.
Related specificationsMozilla Developer Network : [NamedNodeMap Article]
Microsoft Developer Network: [Windows Internet Explorer API reference Article]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4