问题
In this list, how can I count how many ul tags there are below the li.selected? I want ul tags from all levels counted, not just direct children. The return in this example should be 2.
<ul class="theMenu">
<li>
<a href="">Great Britain</a>
<ul>
<li>
<a href="">London</a>
<ul>
<li><a href="">Trafalgar Square</a></li>
<li><a href="">White Heart Lane</a></li>
<li><a href="">Paddington Station</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="">Germany</a></li>
<li>
<a href="">France</a>
<ul>
<li class="selected">
<a href="">Paris</a>
<ul>
<li><a href="">Notre Dame</a></li>
<li>
<a href="">Parc des Princes</a>
<ul>
<li><a href="">Zlatan Ibrahimovic</a></li>
</ul>
</li>
<li><a href="">Sacre Coeur</a></li>
</ul>
</li>
<li><a href="">Rouen</a></li>
<li><a href="">Lyon</a></li>
<li><a href="">Marseilles</a></li>
</ul>
</li>
<li><a href="">Sweden</a></li>
<li><a href="">Poland</a></li>
Cheers / Robin.
来源:https://stackoverflow.com/questions/22235372/count-ul-tags-that-are-children