I have a simple issue that I might just not be thinking through. I am trying to add together several input fields (which are all formatted numbers like 2.00, 3.00, etc.).
But using the following script:
var sum = parseFloat(0).toFixed(2);
//using an iterator find and sum the values of checked checkboxes
$(".amountCheckbox:checked").each(function() {
var input = parseFloat($(this).closest('tr').find('.amountInput').val());
console.log(input.toFixed(2));
sum += input.toFixed(2);
console.log(sum);
});
return sum;
It returns as 02.003.00 rather than 5.00. I would appreciate any help. Thanks!
.toFixed()from your code and just add it once withreturnlikereturn sum.toFixed(), it will solve your problem.