How to select penultimate (last but one) li element from the ul list in jQuery?
$("li:last").prev("li").addClass("class-to-add")
If there's only one list, just pass a negative index to the eq()
[docs] method.
$("ul li").eq(-2).addClass("extra");
Sounds like you're using an older version of jQuery.
Here's an example that shows it working in jQuery 1.3.2
.