2

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 

This is my code:

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

}

The error points to this line:

 row = table.rows(index);

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

4
  • I think you misspelt muscle $("#muslce_order_table"); Commented Jul 29, 2014 at 11:59
  • rob = $('somestuffwhichnotthere'); console.log(rob == null); gives false Commented Jul 29, 2014 at 12:01
  • 1
    Try row = table.find('tr').eq(index); Commented Jul 29, 2014 at 12:02
  • 1
    Please take a look at the selector documentation (api.jquery.com/category/selectors) and the jquery API in general (api.jquery.com), it'll tell you very quicky that rows is not a jQuery method. Commented Jul 29, 2014 at 12:03

1 Answer 1

12

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

row = table.find('tr').eq(index);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.