ZVON > References > DOM1 Reference

getNamedItem (method)

Owning interface and usage:  
NamedNodeMap.getNamedItem(name)

Member of these other interfaces :  
none

Description:  
Retrieves a node specified by name.

Parameters:  
DOMString name  -  Name of a node to retrieve.

Returns:  
Node -  A Node (of any type) with the specified name, or null if the specified name did not identify any node in the map.

Exceptions:  
none


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 output = attrNode.getNamedItem('class').nodeValue;
Output:
desired your browser
white-spaces

preserved

by default
secondClass
white-spaces

not-preserved

by default
fourthClass