Possible Duplicate:
jquery: select the last 4 items in the list
jQuery has the nth-child psuedo-class, but is there a way to select the say 3:rd to last child ?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Assuming you don’t necessarily need to use the
:nth-child()notation, you could use a negative index witheq():JS Fiddle demo.
Or, in compliant browsers, you could simply use CSS:
JS Fiddle demo (tested, and confirmed-working, in Chromium 19/Ubuntu 11.04).
The CSS-selector, presumably thanks to
document.querySelector()/document.querySelectorAll(), is also available as a selector in jQuery:JS Fiddle demo
References:
eq().