gpt4 book ai didi

javascript - 如何在 Javascript 中将 $ 货币替换为 Rp (Rupiah) 格式

转载 作者:行者123 更新时间:2023-11-28 03:58:54 26 4
gpt4 key购买 nike

**我有下面的代码,我想在js中将货币格式从($)更改为(Rp.)。我已经厌倦了这个,有人可以帮助我吗?

function update_total() {
var total = 0;
$('.price').each(function(i){
price = $(this).html().replace("$","");
if (!isNaN(price)) total += Number(price);
});

total = roundNumber(total,2);

$('#subtotal').html("$"+total);
$('#total').html("$"+total);

update_balance();
}

function update_balance() {
var due = $("#total").html().replace("$","") - $("#paid").val().replace("$","");
due = roundNumber(due,2);

$('.due').html("$"+due);
}

function update_price() {
var row = $(this).parents('.item-row');
var price = row.find('.cost').val().replace("$","") * row.find('.qty').val();
price = roundNumber(price,2);
isNaN(price) ? row.find('.price').html("N/A") : row.find('.price').html("$"+price);

update_total();
}

最佳答案

如果您想替换它的唯一 html,则可以使用

replace('$','Rp')

关于javascript - 如何在 Javascript 中将 $ 货币替换为 Rp (Rupiah) 格式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47324247/

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