我有计算数字总和的jquery但是sum将以追加方式显示 [英] i have jquery to calculating the sum of numbers but sum will be displayed in append manner
本文介绍了我有计算数字总和的jquery但是sum将以追加方式显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我hava jquery计算数字总和,但总和将以追加方式显示
下面给出的jquery代码
i hava jquery to calculating the sum of numbers but sum will be displayed in append manner
the jquery code given below
$(.cprice).each(function (i, obj) {
$(obj).html().trim();
total = (total) + (parseInt($(obj).html().trim()));
})
$(#tprice).html(total);
例如:数字是1000,2000,3000
结果将显示在100020003000
i需要显示的总和是6000
eg: the number are 1000, 2000, 3000
the result will be shown in 100020003000
i need to display the sum is 6000
推荐答案
(。cprice).each( function (i,obj){
(.cprice).each(function (i, obj) {
(obj).html()。trim();
total =(total)+( parseInt (
(obj).html().trim(); total = (total) + (parseInt(
(obj).html()。trim()));
})
(obj).html().trim())); })
这篇关于我有计算数字总和的jquery但是sum将以追加方式显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文