count in list js code example
Example 1: JavaScript count list items
var ul = document.getElementById("myul");
var liNodes = [];
for (var i = 0; i < ul.childNodes.length; i++) {
if (ul.childNodes[i].nodeName == "LI") {
liNodes.push(ul.childNodes[i]);
}
}
Example 2: JavaScript count list items
var myUL = document.getElementById("myUL");
var list = myUL.children.tags("LI");
alert(list.length);