The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS [Solved] Tricky :nth-child question Re: [Solved] Tricky :nth-child question

Chris Coyier

Great question! And, I don’t really think so, not with :nth-child or CSS anything anyway.

With jQuery, I’d go something like:

var $collection = $("li");
var numberOfThem = $collection.length;
var nextToLast = $collection[numberOfThem - 1];

so nextToLast is a DOM node of the next to last list item.