秒表js开始结束

来源:互联网 发布:node模块化的优缺点 编辑:程序博客网 时间:2024/05/20 23:36

qq:2579679536

<!doctype html><html>    <head>        <meta charset="UTF-8">        <meta name="Generator" content="EditPlus®">        <meta name="Author" content="">        <meta name="Keywords" content="">        <meta name="Description" content="">        <title>Document</title>     </head>     <body>        <div id="num">0</div>        <input type="submit" name="" id="start" value="开始" />        <input type="submit" name="" id="stop" value="结束" />         <script type="text/javascript">            num=document.getElementById('num');            start=document.getElementById('start');            stop=document.getElementById('stop');            num.innerHTML=0;            ta=1;            start.onclick=function()            {                if(!ta)                {                    num.innerHTML=0;                }                //t=setTimeout(newnum,1000);                t=setInterval(newnum,1000);                this.disabled=true;                stop.disabled=false;                //alert(1);            }            stop.onclick=function()            {                //clearTimeout(t);                clearInterval(t);                this.disabled=true;                start.disabled=false;                ta=0;            }            function newnum()            {                num.innerHTML=parseInt(num.innerHTML)+1;                    //t=setTimeout(newnum,1000);            }         </script>     </body></html>
原创粉丝点击