DOM - Root Node of the document


The root Node is the root of the document tree.

In styling / positioning, the root node is the default node for any absolute positioning



var rootElement = document.documentElement;
var firstTier = rootElement.childNodes;

// firstTier is the NodeList of the direct children of the root element
console.log("The child nodes of the root element are");
for (var i = 0; i < firstTier.length; i++) {
   // do something with each direct kid of the root element
   // as firstTier[i]
   console.log("Node "+i+": Tag Name="+firstTier[i].tagName+", Node Type="+firstTier[i].nodeType);


Powered by ComboStrap