[ACCEPTED]-javascript: getting td index-xhtml
Accepted answer
Get the index of the <td>
first, since it is 3 on the way to the <tr>
:
var cell = $(this).closest('td');
var cellIndex = cell[0].cellIndex
var row = cell.closest('tr');
var rowIndex = row[0].rowIndex;
Or using the parents()
[docs] method 2 along with a multiple-selector
[docs], you could do the selection 1 for both at once:
var cellAndRow = $(this).parents('td,tr');
var cellIndex = cellAndRow[0].cellIndex
var rowIndex = cellAndRow[1].rowIndex;
Source:
stackoverflow.com
More Related questions
Cookie Warning
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.