星空网 > 软件开发 > Java

setTimeout、clearTimeout、setInterval,clearInterval ——小小计时器

先看下效果

setTimeout、clearTimeout、setInterval,clearInterval  ——小小计时器

 

话不多说上代码~

<!DOCTYPE HTML><html>  <head>    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">    <title>计时器</title>    <script type="text/javascript">      var num=0;      var i;      function clockstart(){         document.getElementById('clock').value=num;         num++;         i=setTimeout("clockstart()",1000);      }      function clockstop(){        clearTimeout(i);      }        function clockclear(){        num=0;        setTimeout("document.getElementById('clock').value=0",0);        clearTimeout(i);      }      </script>  </head>  <body>    <input type="text" id="clock" /><br/><br/>    <input type="button" value="开始" onclick="clockstart()" />    <input type="button" value="停止" onclick="clockstop()" />    <input type="button" value="复位" onclick="clockclear()" />  </body></html

 setTimeout、clearTimeout、setInterval,clearInterval  ——小小计时器

代码

<!DOCTYPE HTML><html>  <head>    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">    <title>秒表</title>    <script type="text/javascript">    function clock(){      var time=new Date();      var attime=time.getHours()+":"+time.getMinutes()+":"+time.getSeconds();      document.getElementById('clock').value=attime;    }    setInterval("clock()",100);    </script>  </head>  <body>    <input type="text" id="clock" />  </body></html>

 




原标题:setTimeout、clearTimeout、setInterval,clearInterval ——小小计时器

关键词:

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

账号受限类型:https://www.goluckyvip.com/tag/8361.html
tiktok赚得到钱吗:https://www.goluckyvip.com/tag/83610.html
tiktok播放量100万有钱吗:https://www.goluckyvip.com/tag/83611.html
tiktok影视剪辑赚钱:https://www.goluckyvip.com/tag/83612.html
tiktok挣钱嘛:https://www.goluckyvip.com/tag/83613.html
国外tiktok赚钱是真的吗:https://www.goluckyvip.com/tag/83614.html
珠海附近过年旅游景点 珠海附近过年旅游景点免费:https://www.vstour.cn/a/408243.html
韶关有组团到山西旅游 韶关到山西有多少公里:https://www.vstour.cn/a/408244.html
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流