这是我的代码......
function calculateAmount(plotSize,planRate){
var amount = plotSize*planRate;
var currenamount= ('#totalamount').val();
if(currenamount=='Amount'){
currenamount=0;
}
var c = parseInt(amount) + parseInt(currenamount);
$('#totalamount').val(c);
}
我想添加varriable currenamount和amount,并将其显示在totalamount div中。
答案 0 :(得分:0)
您$
遗漏(#totalamount)
,因此应将当前金额初始化为:
var currenamount= $('#totalamount').val();
^^^ $ here
如评论中所述,如果totalamount
是div,则可以尝试此
var currenamount= ('#totalamount').text();
并将文本设置为div的总金额:
$('#totalamount').text(c);