12.dom children
by John Kiran
HTML
<html>
<body>
<div>Users:</div>
<ul>
<li>John</li>
<li>Pete</li>
</ul>
</body>
</html>
JavaScript
//three ways to get first div element
alert(document.body.firstElementChild);
alert(document.body.children[0]);
alert(document.body.childNodes[1]);
//to get ul
alert(document.body.children[1]);
//to get li
alert(document.body.children[1].childNodes[4]);