March 12, 2012
jquery selectors: how to select all li items from some index to the end?
Question by myWallJSON
So we can select one item li:eq('+(lastItemIndex)+')'
I wonder how to select this item and all items that are next from it to the end? jsfiddle demo here (in which we would like to change all elements in li from 3
to last one
)
Answer by Nicola Peluchetti
You should use nextAll();
var lastItemIndex = 3;
$('li').eq(lastItemIndex).nextAll('li').css("opacity", 0);