我使用以下代码来计算包含和附加增值税价格:
$('#totalexvat').text(totalprice);
var vat = totalprice / 100 * 17.5;
vat = roundNumber(vat,2);
$('#totalincvat').text(totalprice-vat);
有时我会得到 0.3 或 .9,而不是我想要的 0.30 或 0.90,因为这是钱,有办法做到这一点吗?
最佳答案
您可能想看看这个:http://code.google.com/p/jquery-numberformatter/因为您已经在使用 jQuery。
关于jquery - 在小数末尾添加 0 以确保它始终是小数点后 2 位?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2645096/