$.slice(startIndex,endIndex)
slice method is used to select from startIndex to endIndex of selected list of elements by selector in jquery. slice method of jquery is used to select first few elements in jquery elements.
$(element).slice(0,3).css("color","red");
|
<div class="my_div">A</div>
<div class="my_div">B</div>
<div class="my_div">C</div>
<div class="my_div">D</div>
<div class="my_div">E</div>
|
$(function(){
$(".my_div").slice(0,3).css("color","red");
});
|
Demo & Output
|