How to get the updated remaining amount? You are counting remain_amounton a finished document, not when you click the add button. You need to move the calculations to the click handler for #addScnt. Just make it the first line of this function, and it should recount accordingly.
? , , . , .
$('#remScnt').live('click', function() {
if (i > 2) {
var $p = $(this).parents('p');
var textValue = $p.find('input[name="amt[]"]').val();
var numValue = replaceCommaDollar(textValue);
var $remaining = $("#remaining");
var remainingValue = replaceCommaDollar($remaining.text());
var difference = remainingValue - numValue;
var newRemainingValue = numberWithCommas(difference.toFixed(2)))
$("#remaining").text(newRemainingValue);
$p.remove();
i--;
}
return false;
});
, , , i, . DOM , . , , , . , . , , , .
jsFiddle , . , HTML JavaScript, JavaScript.
, ! , , , .