--- title: element.removeAttributeNode slug: Web/API/Element/removeAttributeNode tags: - DOM - Gecko - 翻訳中 translation_of: Web/API/Element/removeAttributeNode ---
{{ ApiRef("DOM") }}
removeAttributeNode
removes the specified attribute from the current element.
removedAttr =element.removeAttributeNode(attributeNode)
attributeNode
is the Attr
node that needs to be removed.removedAttr
is the removed Attr
node.// <div id="top" align="center" /> var d = document.getElementById("top"); var d_align = d.getAttributeNode("align"); d.removeAttributeNode(d_align); // align has a default value, center, // so the removed attribute is immediately // replaced: <div id="top" align="center" />
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.
{{ DOMAttributeMethods() }}
DOM Level 2 Core: removeAttributeNode (introduced in DOM Level 1 Core)