Question

I'm using the jQuery calculation and have just about everything working properly, but I need the total to display as 99.90, not 99.9 (for example).

So .toFixed() isn't working for some reason when it should be! I can't find a mask that would work with this problem. Anyone have any other ideas?

Was it helpful?

Solution

Instead of this line:

$(".sumit").sum("keyup", "#totalSum");

Use:

$('.sumit').keyup(function(){
  var totalsum = $('.sumit').sum();
  $('#totalSum').val(Number(totalsum).toFixed(2));
});

Hope that helps

OTHER TIPS

You can use toFixed

var num = 99.9;
num.toFixed(2);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top