Reputation: 481
I have a <div>
with many <ul>
descendants with different classes, and I am calling a function on this <div>
which modifies the last <ul>
with a given class. How do I select the last <ul>
descendant with a specified class using $(this)
jQuery selector?
Upvotes: 1
Views: 161
Reputation: 4288
i think it should work also.
var uls = $(this).find("ul.someClass")
var lastUl = uls[uls.length - 1];
Upvotes: 0
Reputation: 165951
You can use the last
method:
var last = $(this).find("ul.someClass").last();
Or the :last
selector:
var last = $(this).find("ul.someClass:last");
Upvotes: 5