I have something like this:
<ul>
<li>
<ul class="horizontal">
<li>something</li>
<li>something</li>
</ul>
</li>
<li>
<ul class="horizontal">
<li>something</li>
<li>something</li>
<li>something</li>
</ul>
</li>
<ul>
To count a li i use:
var CountLength = $('.horizontal li').length;
It is returning 5 but that’s the total of all ul.horizontal elements. What i want to know is how do i get it to count the largest ul element.
You could iterate over the set of
.horizontalelements and compare the number of children each has with the current longest:Here’s a working example.