I Have a navigation looking like this
<ul class="navigation">
<li class="navlist">
Navigation1
<ul>
<li>point1</li>
<li>point2</li>
...
</ul>
</li>
<li class="navlist">
Navigation2
<ul>
<li>point1</li>
<li>point2</li>
...
</ul>
</li>
</ul>
etc (4 more navigations) ..
Now I want to select the last and add a class to it with jquery. Normaly I wont be a Porblem. But I have 5 Navigations like this in the code. And it’s only adding the class to the last one using this selector
$('.navigation ul:last').addClass('last_border')
This loops over the
.navigationelements, and selects the lastulin each.Because the
.find("ul:last")is performed from the context of each individual.navigation, the:lastwill only apply to the current.navigationelement.Or because of jQuery’s implicit iteration, you could actually do this:
jQuery will iterate the found
.navigationelements, and perform.find()on each one individually.