ZVON > References > DOM2 Reference

removeNamedItem (method )

Owning interface and usage:  
NamedNodeMap.removeNamedItem(name)

Member of these other interfaces:  
none

Description:  
Removes a node specified by name.

Parameters:  
DOMString name  -  The nodeName of a node to remove.

Returns:  
Node -  The node removed from this map if a node with such a name exists.

Exceptions:  
DOMException NOT_FOUND_ERR
Raised if there is no node named name in this map.
DOMException NO_MODIFICATION_ALLOWED_ERR
Raised if this map is readonly.

Note:  
When this map contains the attributes attached to an element and this attribute is known to have a default value, an attribute immediately appears containing the default value as well as the corresponding namespace URI, local name, and 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 attrNode = main.childNodes[3].attributes;
  var removedNode = attrNode.removeNamedItem('class');
  var output1 = removedNode.nodeValue;
  var output2 = attrNode.getNamedItem('class');
Output:
desired your browser
white-spaces
preserved
by default
output1: secondClass
output2: null
white-spaces
not-preserved
by default
output1: fourthClass
output2: null