计算导致跨度崩溃

时间:2016-09-05 08:29:24

标签: c# jquery

Cacluation是制动功能我正在尝试进行计算,但它正在制动我的其他功能,计算很简单,可以从另一个跨度中取出一个跨度

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>

1 个答案:

答案 0 :(得分:1)

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

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);



      }