This is my HTML Code
<html>
<head>
<title> Test Page </title>
<script type='text/javascript'>
function test() {
var ta = document.getElementsByTagName('body')[0].getElementsByTagName('li');
}
</script>
</head>
<body onload='test()'>
<ul>
<li> Test 1 </li>
<li> Test 1 </li>
<li> Test 1 </li>
<li> Test 1 </li>
</ul>
</body>
</html>
Which of the following is better and why?
document.getElementsByTagName('body')[0].getElementsByTagName('li')
document.getElementsByTagName('li')
Also I couldn't find any documentation or reference for getElementsByTagName implementation across browsers [atleast a overview on some major browsers] although I found really interesting things about document.getElementById that it is kind of hash look up atleast in firefox and chrome. Wish to have some help on the implementation too.