我正在尝试使用 jQuery 在表格中向下移动 X 行...
我可以执行以下操作并且有效......
/* Now let's move next 3 times to arrive at the foo account */
for (var rowCount = 1; rowCount <=3; rowCount++) {
foobarRow = $(foobarRow).next('tr');
}
我知道我可以走了
foobarRow = $(foobarRow).next('tr');
foobarRow = $(foobarRow).next('tr');
foobarRow = $(foobarRow).next('tr');
还有...
但我想知道是否有更 jQueryish 的方式来完成同样的事情?
就像,我不知道,但是(完全由 jQuery 语法组成)...
foobarRow = $(foobarRow).next('tr').number(3);
最佳答案
您可以通过索引匹配元素 :eq(index)
.
$("tr:eq(2)")
选择第三个 <tr>
.请注意,这是一个从零开始的索引。
关于javascript - 使用 jquery 在表中移动 X 行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/444801/