ZVON > References > DOM1 Reference

removeNamedItem (method)

Owning interface and usage:  
NamedNodeMap.removeNamedItem(name)

Member of these other interfaces :  
none

Description:  
Removes a node specified by name. If the removed node is an Attr with a default value it is immediately replaced.

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

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

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


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