jquery :last missing multiple classes
Posted
by mickyjtwin
on Stack Overflow
See other posts from Stack Overflow
or by mickyjtwin
Published on 2010-04-13T06:30:23Z
Indexed on
2010/04/13
6:32 UTC
Read the original article
Hit count: 227
jQuery
|jquery-selectors
I have an unordered list, and am using jquery to find the last ul and apply a class.
jQuery("ul.class1:last").addClass("lastUi");
The html is as follows:
<ul class="class1"></ul>
<ul class="class1"></ul>
This is working fine, however it has now changed in that another class is being added to the list so the html looks like:
<ul class="class1"></ul>
<ul class="class1 class2"></ul>
<ul class="class1"></ul>
<ul class="class1 class2"></ul>
The jQuery code is now not picking up the last ul with both class1 and class2 as the last element and isn't adding the lastUI class.
© Stack Overflow or respective owner