ZVON > References > DOM2 Reference

removeAttributeNode (method )

Owning interface and usage:  
Element.removeAttributeNode(oldAttr)

Member of these other interfaces:  
none

Description:  
Removes the specified attribute node.

Parameters:  
Attr oldAttr  -  The Attr node to remove from the attribute list.

Returns:  
Attr -  The Attr node that was removed.

Exceptions:  
DOMException NO_MODIFICATION_ALLOWED_ERR
Raised if this node is readonly.
DOMException NOT_FOUND_ERR
Raised if oldAttr is not an attribute of the element.

Note:  
If the removed Attr 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.


Example:
Text in the first DIV.
Some text in the second DIV.
Some text and element in the third DIV.
We can try another elements. It will be much more interesting.
Text in the last DIV.
Source:
   <div id="doc">
     <div>
       Text in the first DIV.
     </div>
     <div id="DDD" class="secondClass">
       Some text in the second DIV.
     </div>
     <div class="thirdClass">
       Some text and <span id="SSS">element</span> in the third DIV.
     </div>
     <div class="fourthClass">
       We can try <i>another elements</i>.
       It will be much more <b>interesting</b>.
     </div>
     <div>
       Text in the last DIV.
     </div>
   </div>
     
JavaScript:
  var main = document.getElementById('doc');
  var attr = main.attributes[0];
  var attrOut = main.removeAttributeNode(attr);
  var output1 = main.getAttributeNode('id');
  var output2 = attrOut.value;
Output:
desired your browser
output1: null
output2: doc