<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <span id="begin">开始</span> <span id="stop">结束</span> <script> var n=0; var timer; var begin=document.getElementById("begin"); var stop=document.getElementById("stop"); begin.onclick=function () { timer=setInterval(function () { n++; document.getElementById("result").innerHTML=n; },1000) } stop.onclick=function () { clearInterval(timer) } </script> </head> <body> <div id="result"></div> <p οnclick="window.open('http://www.w3school.com.cn/')">打开</p> <p οnclick="window.close()">关闭</p> </body> </html>
jQuery计时器
最新推荐文章于 2020-06-01 16:32:34 发布