Reputation: 2815
I am looking for a jQuery selector to find the last li of several nested lists. The structure will be deeper than this in reality, but I figure a selector that could get these two should probably work.
<ul>
<li>
<a>some link</a>
<ul>
<li>
<a>not this one</a>
</li>
<li>
<a>this one</a>
<ul>
<li>
<a>also not this one</a>
</li>
<li>
<a>and this one too</a>
</li>
</ul>
</li>
</ul>
</li>
</ul>
Upvotes: 0
Views: 1504
Reputation: 348972
$('li:last-child > a');
Will select every <a>
element, which is a child of the last <li>
of every <ol>
or <ul>
list.
Upvotes: 1