Incrementing numeric content of td cell after adding row to table
I use the following to add a new row to a table:
- $(".add-row").live('click', function(){
- var thisTableId = $(this).parents("table").attr("id");
- var lastRow = $('#'+thisTableId + " tr:last");
- var newRow = lastRow.clone(true);
- $('#'+thisTableId).append(newRow);
- $('#'+thisTableId + " tr:last td :input").val('');
- return false;
- });
The form data is cleared, however, the first td cell contains a counter, so when a new row is added, the last number is displayed. For example, if there are 3 rows, the first td cell for each row contains 1, 2, 3, and adding a new row display 3 again. How can it be done so that instead of 3, it displays the next number each time a row is added? Thanks.