Use document.getElementById("items").childNodes.length and a number comparison operator. If your ul contains other nodes than li , you will have to filter them out.
In jQuery:
$("#items").children("li").length
I think you only need direct children, so do not use find ().
Bergi source share