获取表逐行索引jquery [英] Get table row by row index jquery

查看:69
本文介绍了获取表逐行索引jquery的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用行索引访问表中的行.

I want to access row in my table using the row index.

当我尝试通过索引获取行时,我得到了:

When I try to get the row by is index I get :

Uncaught TypeError: undefined is not a function 

这是我的代码:

function moveUpMuscle(muscleIdFrom, muscleOrderFrom, index)
{

    if(index == 0)
    {
        alert("Muscle is already at the top of the list");
        return;
    }

    table = $("#muslce_order_table");

    console.log(table == null ? "null" : "not null");

    row = table.rows(index);

    muscleIdTo = row.attr("data-id");
    muscleOrderTo = row.attr("data-order");

    console.log("muscleIdFrom " + muscleIdFrom + " muscleOrderFrom " + muscleOrderFrom);
    console.log("muscleIdTo " + muscleIdTo + " muscleOrderTo " + muscleOrderTo);

}

错误指向此行:

 row = table.rows(index);

在我的控制台中,日志为"not null",因此table元素未定义.

In my console the log is "not null" so the table element is not undefined.

推荐答案

.rows不是jQuery方法.更改代码以按如下方式检索行

.rows is not a jQuery method. Change your code to retrieve the row as follows

row = table.find('tr').eq(index);

这篇关于获取表逐行索引jquery的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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