nodeName and nodeValue Properties

nodeName and nodeValue give specific information about the node. The values of nodeName and nodeValue are dependent on the node type.

 
<!DOCTYPE HTML> 
<html> 
    <head> 
        <title>Example</title> 

    </head> 
    <body> 
        <pre id="results"></pre> 
        <script> 
            var resultsElement = document.getElementById("results"); 
            document.writeln(resultsElement.nodeType); 
            document.writeln(resultsElement.nodeName); 
        </script> 
    </body> 
</html>
  
Click to view the demo

For elements, nodeName is always equal to the element's tag name, and nodeValue is always null.

Home 
  JavaScript Book 
    DOM  

DOM Model:
  1. Document Object Model
  2. nodeName and nodeValue Properties
  3. Node Relationships:childNodes
  4. parentNode
  5. previousSibling and nextSibling properties
  6. lastChild and firstChild
  7. appendChild() adds a node to the end of the childNodes list
  8. insertBefore()
  9. ownerDocument property
  10. removeChild
  11. replaceChild()
  12. Working with Text
  13. Check the length of NodeList
  14. Convert NodeList to an Array
  15. html tag and its cooresponding JavaScript class