DOM - Root Node of the document

> (World Wide) Web - (W3|WWW) > The Document Object Model W3C API Interface (DOM)

1 - About

Root Node of the document

3 - Javascript

Document/documentElement

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);
}

where:

Advertising
web/dom/root.txt ยท Last modified: 2019/02/09 11:41 by gerardnico