javascript div类变量sum或add math

时间:2015-08-21 10:17:02

标签: javascript

<span class="simpleCart_grandTotal"></span>
<script type="text/javascript">
function totall(){
 var sum = parseInt(simpleCart_grandTotal.value);
if(parseInt(sum.value))
        totall += parseFloat(sum) *20;
});
$('#totall').text( +totall); }
</script>
<div class="totall"></div>  

我希望simpleCart_grandTotal类值乘以20,结果变成div类。

1 个答案:

答案 0 :(得分:0)

<span class="simpleCart_grandTotal"></span>
<script type="text/javascript">
function totall(){
 var sum = $('.vote-count-post').text()
if(Number($('.vote-count-post').text()) == $('.vote-count-post').text())
        $('.totall').text( Number(sum) + Number($('.totall').text()) )
});}
</script>
<div class="totall"></div>