Count Number of List Items with jQuery

So you want to know how many items are in that list:

<ul id="imagelist">
	<li>Image 1</li>
	<li>Image 2</li>
</ul>

 

Make sure you’ve got the jQuery libaray running and run the following lines after page load.

$(document).ready(function(){
alert($("#imagelist li").size());
});

Back to Blog