I'm trying to create an array of <li>
that are in a div. So I have
var arr = document.getElementById('mainNav').getElementsByTagName('li');
For testing purposes, I put an alert("test"); alert(arr.length);
to see if an alert will pop up and what the size of the array is. Neither of the alerts showed up, but if I place an alert before that variable declaration, it works fine. What could be going wrong?
Thanks, Hristo