问答详情
源自:8-6 取消计时器clearTimeout()

setTimeout()这节的练习没有点击实行

要运行函数的吗。上一节那道练习不会,

提问者:慕粉3283683 2017-02-12 16:43

个回答

  • weixin_sunny_17
    2017-02-12 18:53:16

    代码粘给你!

    <!DOCTYPE HTML>
    <html>
    <head>
    <script type="text/javascript">
    var num=0;
    function numCount(){
     document.getElementById('txt').value=num;
     num=num+1;
     setTimeout("numCount()",1000);
     }
    </script>
    </head>
    <body>
    <form>
    <input type="text" id="txt" />
    <input type="button" value="Start" onClick="numCount()" />
    </form>
    </body>
    </html>