Possible Duplicate:
Selecting the first “n” items with jQuery
Code :
<div class="prova">Hello</div>
<div class="prova">Hello</div>
<div class="prova">Hello</div>
<div class="prova">Hello</div>
<div class="prova">Hello</div>
<div class="prova">Hello</div>
<div class="prova">Hello</div>
<div class="prova">Hello</div>
<div class="prova">Hello</div>
<div class="prova">Hello</div>
$('.prova:gt(' + 0 + '):lt(' + 5 + ')').html("Hello Edited");
I’d like to edit the first 5 elements. Why it ignores the first one? (which should be index 0).
Use
.sliceinstead of:gtor:ltfor optimum performance: