JQuery: find last child with specific class

If I have a deep nested unordered list and I have a link to the root node, is there a built-in way to find the last type of type li that has a specific css class? For example, if I have a tree branch of 5 levels, and the branch expands to the thrid level, levels 1,2,3 will have a reset class. Now I want to find the last "li" in this case, at level 3, which this class has.

+7
jquery
source share
1 answer

Not too complicated:

$("li.someclass", rootOfList).last() 

searches for rootOfList for last li with someclass class

+13
source share

All Articles