I used the code below to build a table (tablejq). When adding rows, the total-field (totalInTable) gets updated perfectly, but when a row is deleted using the 'x', the total-field remains the same. Can someone please help. Thank you.
My code is:
$(document).ready(function() {
rowcount();
$('.tablejq').on('click', '.form-del-field', function () {
rowcount();
});
$('.tablejq').on('click', '.cf-table-add-row', function () {
rowcount();
});
function rowcount() {
$('.totalInTable input').val($('.tablejq tr').length-1);
}
});