如何在Javascript中用Rp(卢比)格式替换$currency
**我在下面有一个代码,我想在js中将货币格式从($)改为(Rp.)。我受够了,有人能帮我吗如何在Javascript中用Rp(卢比)格式替换$currency,javascript,Javascript,**我在下面有一个代码,我想在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)
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')
如果你只想替换html,你可以使用
replace('$','Rp')
好的,谢谢你,虽然我上面说的是印尼卢比,不是印度卢比:)好的,谢谢你,虽然我上面说的是印尼卢比,不是印度卢比:)