Element.removeAttributeNode

  • Revision slug: DOM/element.removeAttributeNode
  • Revision title: element.removeAttributeNode
  • Revision id: 71268
  • Created:
  • Creator: Sheppy
  • Is current revision? No
  • Comment 27 words added, 2 words removed

Revision Content

{{ DomRef() }}{{ deprecated_header("7.0") }}

Summary

removeAttributeNode removes the specified attribute from the current element.

Note: This method has been deprecated; you should use {{ domxref("Element.removeAttribute()") }} instead.

Syntax

removedAttr = element.removeAttributeNode(attributeNode)
  • attributeNode is the Attr node that needs to be removed.
  • removedAttr is the removed Attr node.

Example

// <div id="top" align="center" />
var d = document.getElementById("top"); 
var 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 (unlike the pair setAttributeNode and setAttributeNodeNS which need to know which existing attribute to replace (if any), removeAttributeNode has no such requirement). removeAttributeNode can remove namespaced as well as non-namespaced attributes.

{{ DOMAttributeMethods() }}

Specification

DOM Level 2 Core: removeAttributeNode (introduced in DOM Level 1 Core)

{{ languages( { "fr": "fr/DOM/element.removeAttributeNode", "ja": "ja/DOM/element.removeAttributeNode", "pl": "pl/DOM/element.removeAttributeNode" } ) }}

Revision Source

<p>{{ DomRef() }}{{ deprecated_header("7.0") }}</p>
<h3 name="Summary">Summary</h3>
<p><code>removeAttributeNode</code> removes the specified attribute from the current element.</p>
<div class="note"><strong>Note:</strong> This method has been deprecated; you should use {{ domxref("Element.removeAttribute()") }} instead.</div>
<h3 name="Syntax">Syntax</h3>
<pre class="eval"><em>removedAttr</em> = <em>element</em>.removeAttributeNode(<em>attributeNode</em>)
</pre>
<ul> <li><code>attributeNode</code> is the <code>Attr</code> node that needs to be removed.</li> <li><code>removedAttr</code> is the removed <code>Attr</code> node.</li>
</ul>
<h3 name="Example">Example</h3>
<pre>// &lt;div id="top" align="center" /&gt;
var d = document.getElementById("top"); 
var d_align = d.getAttributeNode("align"); 
d.removeAttributeNode(d_align); 
// align is now removed: &lt;div id="top" /&gt;
</pre>
<h3 name="Notes">Notes</h3>
<p>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.</p>
<p>There is no <code>removeAttributeNodeNS</code> (unlike the pair <code>setAttributeNode </code>and<code> </code><code>setAttributeNodeNS</code> which need to know which existing attribute to replace (if any), <code>removeAttributeNode <span style="font-family: Verdana,Tahoma,sans-serif;">has no such requirement</span></code>). <code>removeAttributeNode </code>can remove namespaced as well as non-namespaced attributes.</p>
<p>{{ DOMAttributeMethods() }}</p>
<h3 name="Specification">Specification</h3>
<p><a class="external" href="http://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-D589198">DOM Level 2 Core: removeAttributeNode</a> (introduced in <a class="external" href="http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#method-removeAttributeNode">DOM Level 1 Core</a>)</p>
<p>{{ languages( { "fr": "fr/DOM/element.removeAttributeNode", "ja": "ja/DOM/element.removeAttributeNode", "pl": "pl/DOM/element.removeAttributeNode" } ) }}</p>
Revert to this revision