Alex Rivera | Logout

jquery selector - exclude first and second

Asked 2012-05-11T08:31:23.440
17

I want to exclude first and second element from jquery selector. I tried this:

$('p:not(:nth-child(1),:nth-child(2))')

But this only excludes the first element... Thanks

Edit
Report

1 Answer

33

This jQuery sequence uses .slice() to discard the first two elements from the $('p') selector:

$('p').slice(2).

see http://jsfiddle.net/alnitak/zWV7Z/

Note that this is not the same as nth-child - the exclusion is based on the whole set of elements found in the first selector, and not on their relative position in the DOM.

answered 2012-05-11T08:36:11.213

Your Answer