问答详情
源自:4-4 编程练习

单机按钮票数加一,用total.innerHTML = parseInt(total.innerHTML) + 1可以,但要是用var num = total.innerHTML 把total.innerHTML 都替换掉就不行,为什么

<script>

        function vote(e){

            var total = document.getElementById("total");

            var num = total.innerHTML;

            num = parseInt(num)+1;         //这样就没效果

        }

</script>

提问者:答答安 2016-01-15 11:12

个回答

  • 薇薰草
    2016-01-22 15:29:30

    你没把num赋值给total.innerHTML当然没效果了