计算导致跨度崩溃

本文关键字:崩溃 计算 | 更新日期: 2023-09-27 18:05:51

计算是制动函数我试图做一个计算但它制动我的其他函数计算很简单从另一个span中取出一个span

Jquery

 function caclulateBalance() {
          incomescic = +$('#sumTotalIncome').text();
          expensecic = +$('#expendureTotalSum').text();
          reducible = +$('#reducibleSumTotal').text();
          incomes = +$('#totalsIncomeiande').text();
          expenses = +$('#totalexpensessum').text();                     

          $('#Total').text(incomescic - expensecic + reducible ).toFixed(2);              
}
Html

Income: <strong><span id="totalbalancesum">143</span></strong>
expenses:<strong><span id="totalbalancesum">143</span></strong>
<span id="expenses" >60</span>
Reducible: <strong><span id="reducibleSumTotal">143</span></strong>
<span id="expenses" >60</span>
<span id="Total" >answer should be 23 and displayed here</span>

计算导致跨度崩溃

假设这些元素是输入,执行以下操作

function caclulateBalance() {
         var incomescic = parseFloat($('#sumTotalIncome').text()),
          expensecic = parseFloat($('#expendureTotalSum').text()),
          reducible = parseFloat($('#reducibleSumTotal').text()),
          incomes = parseFloat($('#totalsIncomeiande').text()),
          expenses = parseFloat($('#totalexpensessum').text()),
          total = (incomescic - expensecic + reducible).toFixed(2);
          $('#totalbalancesum').text(total);

      }