此脚本返回#total
,并且显示为类似10920
的数字。如何使它返回数字为$10,920
?
该0如何以货币格式返回,例如$ 1,200
<script>
function add() {
var value1 = document.getElementById('total1').value || 0;
var value2 = document.getElementById('total').value || 0;
var value3 = document.getElementById('totalz1').value || 0;
document.getElementById('sum').innerHTML = parseInt(value1) + parseInt(value2) + parseInt(value3);
}
</script>