gpt4 book ai didi

jquery - 在小数末尾添加 0 以确保它始终是小数点后 2 位?

转载 作者:行者123 更新时间:2023-12-01 07:02:01 24 4
gpt4 key购买 nike

我使用以下代码来计算包含和附加增值税价格:

$('#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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com