this is my html table structure with some columns now i want to add new column srno which will auto generate number whenever i will add row to table then it will auto increment like 1,2,3 etc.
var div;
var data1 = JSON.stringify(getAllInventoryRecords());//used to get data from controls
var d1 = JSON.parse(data1);
// alert(d1);
for (var i = 0; i < d1.length; i++) {
// alert(tabledata[i].DocumentNumber);
tr = $('<tr/>');
tr.append("<td>" + d1[i].description + "</td>");
tr.append("<td>" + d1[i].Qty + "</td>");
tr.append("<td>" + d1[i].unitprice + "</td>");
tr.append("<td >" + d1[i].value + "</td>");
tr.append("<td>" + d1[i].disc + "</td>");
tr.append("<td>" + d1[i].tax +"%", "</td>");
tr.append("<td>" + d1[i].cgst + "</td>");
tr.append("<td>" + d1[i].sgst + "</td>");
tr.append("<td>" + d1[i].igst + "</td>");
tr.append("<td><button id='btndelete' style='height:28px;width:107px;' class='btn btn-default btn-sm'><i class='glyphicon glyphicon-ok'></i> Delete</button></td>");
$('#tblCustomers').append(tr);
$('#lbltotal').html(d1[i].value);//this label is use to get sum of value column
}
Example
-------------------------------------------------------------
Sr No.|description | Qty | unitprice | value |disc |tax |cgst
1 | Cycle |2 |1 |1 |ss |1 |1
2 | AC |2 |2 |4 |qq |1 |2