I want to get the calculation of the sum of the values that are inside these inputs when the page loads automatically, and when I change the values also, the recalculation should be done .and olso when I delete or Add new dynamic row I should get the new sum total include the new value or when I delet row I should get new total .
<table id="dynamic">
<tr>
<th class="wd-15p fontColor">Quantity</th>
<th class="wd-15p fontColor">Amount</th>
</tr>
<tr>
<td class="td"><input type="number" value="1000" name="quantity[]" class="form-control quantity"/></td>
<td class="td"><input type="number" value="1000" name="amount[]" class="form-control amount"/></td>
</tr>
<tr>
<td class="td"><input type="number" value="1000" name="quantity[]" class="form-control quantity"/></td>
<td class="td"><input type="number" value="1000" name="amount[]"class="form-control amount"/></td>
</tr>
<tr>
<td class="td"><input type="number" value="1000" name="quantity[]" class="form-control quantity"/></td>
<td class="td"><input type="number" value="1000" name="amount[]" class="form-control amount" /></td>
<td class="td2"><button type="button" name="add" id="add-btn" class="btn btn-success">Add More</button></td>
</tr>
</table>
<input type="text" class="form-control sum_of_quantity" readonly> <input type="text" class="form-control sum_of_amount" readonly >
$("#add-btn").click(function() {
$("#dynamic").append('<tr><td class="td"><input type="number" name="quantity" class="form-control quantity"/></td>
<td class="td"><input type="number" value="1000" name="amount" class="form-control amount"/></td>
<td class="td2"><button type="button" value="1000" name="add" class="btn btn-danger remove-tr">Remove</button></td></tr>');
});
$(document).on('click', '.remove-tr', function() {
$(this).parents('tr').remove();
});
$(document).ready(function() {
var total =0;
$('.quantity').each(function() {
total += parseFloat($(this).val());
$('.sum_of_quantity').val(total);
});
var sum =$('.one').val();
$(".quantity").on("change keyup", function() {
sum += parseFloat($(this).val());
$('.one').val(sum).toFixed(2);
});
});