I’m trying to move X number of rows down in a table using jQuery…
I can do the following and it works….
/* Now let's move next 3 times to arrive at the foo account */ for (var rowCount = 1; rowCount <=3; rowCount++) { foobarRow = $(foobarRow).next('tr'); }
I realize I could go
foobarRow = $(foobarRow).next('tr'); foobarRow = $(foobarRow).next('tr'); foobarRow = $(foobarRow).next('tr');
also…
but I’m wondering if there’s not a more jQueryish way to accomplish the same thing?
like, I don’t know, but(totally made up jQuery syntax follows)…
foobarRow = $(foobarRow).next('tr').number(3);
You can match elements by their index
:eq(index).$('tr:eq(2)')selects the third<tr>. Note, this is a zero-based index.