使用jquery在表中移动X行数 [英] Move X number of rows in a table using jquery

查看:86
本文介绍了使用jquery在表中移动X行数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用jQuery在表格中向下移动X行...

I'm trying to move X number of rows down in a table using jQuery...

我可以执行以下操作并且它有效.... / p>

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');
}

我意识到我可以去

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

还......

但是我我想知道是否有更多的jQueryish方法来完成相同的事情?

but I'm wondering if there's not a more jQueryish way to accomplish the same thing?

喜欢,我不知道,但是(完全由jQuery语法组成) 。

like, I don't know, but(totally made up jQuery syntax follows)...

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


推荐答案

您可以按索引匹配元素 :eq(index)

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

$(tr:eq(2))选择第三个< tr> 。请注意,这是一个从零开始的索引。

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

这篇关于使用jquery在表中移动X行数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆