views:

216

answers:

1

i am getting all checkboxes that are in an html table using this code and i need to find the current row in the table from the current checkbox.

            var checkboxes = $("form :checkbox");
            for (i = 0; i <= checkboxes.length; i++) {

                var checkbox = checkboxes[i];

                ///need to get current row in html table here 
            }
+1  A: 
  var checkboxes = $("form :checkbox");
    for (i = 0; i <= checkboxes.length; i++) {

        var checkbox = checkboxes[i];

        var rowIndex = $(checkbox).closest('tr')[0].rowIndex;
    }

should do it

Russ Cam
you got me in the right direction. i updated your answer to the final solution
ooo
changed just slightly to use the index instead of the `get()` call (one less function call).
Russ Cam