Deal with nested nodes
<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)"> <div id="div1"> <h1>Header</h1> <p>P1.</p> <p>P2</p> <h2>Header 2</h2> <p>P1.</p> <p>P2</p> </div> </body> </html>