Possible Duplicate:
Selecting the first “n” items with jQuery
I have an infinite countable list of elements!
Is there a function to find x elements from the head of the list and stop!
$('.elements').find('li').limit(10) //this does not work
I tried the goog but i could not be specific enough with the ? !
Try jQuery slice. Your code will be something like this:
$('.elements').find('li').slice(0,10);
UPDATE
As suggested by Marius Miliunas and T.J. Crowder, based on performance, you can just do this:
$('.elements li').slice(0,10);
Yes, you can use jQuery's custom :lt
selector for that.
For instance, this will find only the first three li
s in the given target list:
var firstThree = $("#target li:lt(3)");
Live Example | Source
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With