我是 JS 和這段代碼的初學(xué)者$('.brutto_amount').each(function (index, value) { let amount = $(this).text().replace(' brutto / rok', '').replace('(', ''); console.log(amount); if (discountType == 0) { let newAmount = (amount - discountValue).toFixed(2); if(newAmount < 0) newAmount = 1; $(this).html(`${newAmount} brutto / rok `); } else if (discountType == 1) { let newAmount = (amount - ((parseInt(amount) * parseInt(discountValue)) / 100)).toFixed(2); if(newAmount < 0) newAmount = 1; $(this).html(`${newAmount} brutto / rok `); }});到目前為止工作正常。如何從變量中減去 23% 的增值稅newAmount并將其四舍五入到小數(shù)點(diǎn)后兩位?
從 JavaScript 中的數(shù)字中減去增值稅
慕容3067478
2023-01-06 11:27:10