Baseline Widely available
The removeAttributeNode()
method of the Element
interface removes the specified Attr
node from the element.
If you don't need to inspect the attribute node before removing it, you can use the Element.removeAttribute()
method instead.
removeAttributeNode(attributeNode)
Parameters
attributeNode
The attribute node to remove from the element.
The attribute node that was removed.
ExceptionsNotFoundError
DOMException
Thrown when the element's attribute list does not contain the attribute node.
// Given: <div id="top" align="center" />
const d = document.getElementById("top");
const d_align = d.getAttributeNode("align");
d.removeAttributeNode(d_align);
// align is now removed: <div id="top" />
Notes
If the removed attribute has a default value, it is immediately replaced. The replacing attribute has the same namespace URI and local name, as well as the original prefix, when applicable.
There is no removeAttributeNodeNS
method; the removeAttributeNode
method can remove both namespaced attributes and non-namespaced attributes.
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.3