With Jquery, I need to select just the first "n" items from the page, for example the first 20 links instead of selecting all of them with the usual
$("a")
Sounds simple but the jQuery manual has no evidence of something like this.
With Jquery, I need to select just the first "n" items from the page, for example the first 20 links instead of selecting all of them with the usual
$("a")
Sounds simple but the jQuery manual has no evidence of something like this.
Use lt pseudo selector:
$("a:lt(n)")
This matches the elements before the nth one (the nth element excluded). Numbering starts from 0.
Try the :lt selector: http://docs.jquery.com/Selectors/lt#index
$('a:lt(20)');
You probably want to read up on slice. You code will something like this:
$("a").slice(0,20)