Move X number of rows in a table using jquery

I am trying to move X number of rows in a table using jQuery ...

I can do the following and it works.

/* Now let move next 3 times to arrive at the foo account */ for (var rowCount = 1; rowCount <=3; rowCount++) { foobarRow = $(foobarRow).next('tr'); } 

I understand that I can go

  foobarRow = $(foobarRow).next('tr'); foobarRow = $(foobarRow).next('tr'); foobarRow = $(foobarRow).next('tr'); 

and...

but I wonder if there is no more jQueryish way to accomplish the same thing?

sort of, I don’t know, but (fully written jQuery syntax follows) ...

 foobarRow = $(foobarRow).next('tr').number(3); 
+1
source share
2 answers

You can match elements by index :eq(index) .

$("tr:eq(2)") selects the third <tr> . Note that this is a zero based index.

+5
source

This should do it:

 foobarRow = $(foobarRow).siblings().get(2); 
+1
source