我有静态文字净薪水。现在我想以数字和语言形式添加Salary如何在html中添加它们
HTML
<div id="net_table" class="col-md-12">
<p id="net_sum" class="net-salary-txt"><strong>Net Salary: </strong><span id="digits"></span><span id="words"></span>
</p>
</div>
脚本
//Total Salary
$('#net_table').each(function(){
var income_total=($('#income_total').text()||0);
var deduction_total=($('#deduction_total').text()||0);
var sum = parseInt(income_total) + parseInt(deduction_total);
var numToWords=numToWords(sum);
var digits = document.getElementById("digits");
var words = document.getElementById("words");
digits.appendChild(sum);
words.appendChild(numToWords);
});
答案 0 :(得分:1)
而不是“appendChild”
digits.innerHTML = sum;
words.innerHTML = numToWords;
答案 1 :(得分:0)
对于数字到字的转换,请参阅此链接
Number to word
您可以使用jquery text()函数代替appendChild
$('#digits').text(sum);
$('#words').text(numToWords);