I simply want to search that which <ul>
has the most <li>
? How would I do that?
Like there's an html page containing
<ul>
<li>1</li>
</ul>
<ul>
<li>1</li>
<li>1</li>
<li>1</li>
</ul>
<ul>
<li>1</li>
<li>1</li>
</ul>
Now then I want to show <ul>
number 2 has the most <li>
s. It can be done via PHP.
Thanks
The best solution is to use jQuery for this - it may loo like this
var largestUl = null;
$('ul').each(function () {
if (largestUl == null) {
largestUl = this;
} else {
if ($(largestUl, 'li').length > $(largestUl, 'li').length) {
largestUl = this;
}
}
});