I would like to know, how can I skip first N elements in JQuery. Something like this:
1
2&l
-
jQuery has a gt selector. (Greater than).
$('#test > div:gt(1)')
Or you can use the slice function
$('#test > div').slice(2)
讨论(0)
-
Skip just the first one - example:
$("#spaccordion li:gt(0)").addClass("collapsed");
All <li>
items will have class "collapsed" except the first one
讨论(0)
-
I think you are looking for the :gt
selector: http://api.jquery.com/gt-selector/
Note that you start counting from 0 here.
Try:
$('#test > div:gt(1)')
讨论(0)
-
Use the .slice() function, it gives you the subset of elements based on its index.
$('#test > div').slice( 2 )
Reference: http://api.jquery.com/slice/
讨论(0)