JavaScript DHTML/Node Operation/childNodes

Материал из Web эксперт
Перейти к: навигация, поиск

Deal with nested nodes

   <source lang="html4strict">
 

<html> <head> <title>The Node</title> <script type="text/javascript"> function outputNodeProps(nd) {

  if (nd.style) {
     
     nd.style.backgroundColor="red";
  }
  var children = nd.childNodes;
  for(var i=0; i < children.length; i++) {
     outputNodeProps(children[i]);
  }

} </script> <body onload="outputNodeProps(document)">

Header

P1.

P2

Header 2

P1.

P2

</body> </html>


 </source>