How to count the number of li inside of ul
-
This script run after the whole page load or you can use document ready instead of onload method.
Example HTML code:
- 1
- 3
- 4
<script>
$(document).ready(function(){
count = $(“li”).children().length;
alert(count);
});or
jQuery(window).bind(“load”, function(){
count = $(“li”).children().length;
alert(count);
});
</script>the output is 3.
- The topic ‘How to count the number of li inside of ul’ is closed to new replies.