Using jQuery, how to select a range of strings?

Is there only jQuery solution to select a range of rows from a table?

I know "eq", "lt", "gt", but I am looking for a combination of these selectors.

+5
source share
5 answers

You can apply several filters at a time, although the second filter applies to the results of the first, so the following will mean starting from the 4th line (skips 0..2) and selects 3 lines (includes 0..2):

$('#t tr:gt(2):lt(3)').css('background-color', '#f00');
+18
source

: gt() jQuery... : gt() ... $( "css-selector" ). slice (index) .

, slice .

$('ul > li').slice(start, end).css("color", "blue")

: http://api.jquery.com/gt-selector/

+3

jQuery filter; - .

+1

You can use the nthChild selector with an argument to an equation.

0
source

You can bind your "eq", "lt", "gt", and this will gradually filter each subsequent returned array.

0
source

All Articles