I have HTML code structure:
<ul id="main">
<li>
<a href="#"></a>
<ul>
<li><a href="#"></a></li>
<li><a href="#"></a></li>
<li><a href="#"></a></li>
</ul>
<li>
</ul>
Want to select all elements inside UL id="main".
Tried to use:
var el = document.getElementById("main").getElementsByTagName("*");
for (var i=0; i<el.length; i++) {
alert(el[i].tagName);
}
But only get LI and A tags. UL tags are missing. Any ideas ?