Javascript将数字添加为字符串
作者:互联网
我有以下代码将数字解释为字符串,并将它们添加为100300而不是400:
var rate = document.getElementById('pur_price').value;
var pprice = document.getElementById('pur_price').value;
var rate1 = document.getElementById('select2').value;
var refurb = 300;
document.getElementById('avg_claim_rate').value=id;
document.getElementById('amount_claim').value=pprice+refurb;
它是pprice和refurb字段,所以如果pprice = 100并且refurb = 300,我预计它会显示400,其中显示100300
解决方法:
var result = +pprice + + refurb;
标签:addition,javascript,variables,math 来源: https://codeday.me/bug/20191003/1847011.html