I\'m working on making a dynamic HTML table using jQuery. In a table, my user has two interactions:
The
http://jsfiddle.net/mblase75/LNXae/1/
First, wrap the counter number in a with a class for easy finding later:
$new_row.children('td').prepend('Row #' + ($new_row.index() + 1) + "");
Then update all these spans with an .each
loop after you remove the desired row. The first argument passed into .each
's callback function is a zero-based index number, and the second is the HTML element:
var $row = $(this).closest('tr'),
$table = $row.closest('table');
$row.remove();
$table.find('tr').each(function(i, v) {
$(v).find('span.num').text(i + 1);
});