I have the following HTML:
<input id="1" type="checkbox"/>
<label for="1">bla bla</label>
<br/>
<input id="2" type="checkbox"/>
<label for="2">hello hello</label>
<br/>
.
.
.
etc...
Is there a way to select first few inputs here in one call? In other words, I don’t want to select them all and loop through each one. Just 1 statement to select, for example, first 3.
The jQuery function slice lets you specify only a subset of the results:
Where 0 is the first index and 3 is the first index not included, so 2 is the last index and you get the three items.