简单计时器

来源:互联网 发布:港股模拟软件 编辑:程序博客网 时间:2024/05/22 23:40
<!DOCTYPE html><html>    <head>        <meta charset="utf-8" />        <title></title>    </head>    <script>            var i = 0;            var start;            window.onload = function(){                document.getElementById("btn").onclick = function(){                    start = setInterval("addTime()",1000);                }                document.getElementById("clo").onclick = function(){                    clearInterval(start);                }            }            function addTime(){                i++;                document.getElementById("show").innerHTML = i;            }        </script>    </head>    <body>        <div id="show"></div>        <button id="btn">计时开始</button>        <button id="clo">计时终止</button>    </body></html>

这里写图片描述

原创粉丝点击