菜单切换
FACESOHO知行者
心灵
记录
远方
赞赏工具
源代码:
点击运行
保存
<!DOCTYPE html> <html><head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> </head> <body> <form name="display1"> <input type="text" id="box1" name="box1" value="0" size="4" /> <input type="button" value="停止计时" onclick="clearTimeout(meter1)" /> <input type="button" value="继续计时" onclick="count1() " /> </form> <p></p> <form name="display2"> <input type="text" id="box2" name="box2" value="0" size="4" /> <input type="button" value="停止计时" onclick="clearTimeout(meter2) " /> <input type="button" value="继续计时" onclick="count2() " /> </form> <span id="monitor" style="top:100px;right:100px;position:fixed;z-index:10000;color:red">原来的内容</span> clearTimeout(timeoutID) timeoutID 为调用 setTimeout() 函数时所获得的返回值,使用该返回标识符作为参数,可以取消该 setTimeout() 所设定的定时执行操作 <script> x = 0 y = 0 function count1(){ x = x+ 1 document.getElementById("box1").value= x meter1=setTimeout("count1()", 1000) } function count2(){ y = y+ 1 document.getElementById("box2").value= y meter2=setTimeout("count2()", 1000) } count1() count2() </script> </body> </html>
运行结果