A repository of over 1000 quality jQuery plugins

jQuery :nth-last-child() Selector

Learn all about the jQuery function :nth-last-child() Selector.

Because jQuery’s implementation of :nth- selectors is strictly derived from the CSS specification, the value of n is "1-indexed", meaning that the counting starts at 1. For other selector expressions such as :eq() or :even jQuery follows JavaScript’s "0-indexed" counting. Given a single <ul> containing three <li>s, $( "li:nth-last-child(1)" ) selects the third, last, <li>.

Further discussion of this usage can be found in the W3C CSS specification.