标签:
| <!doctype html> | |
| <html lang="en"> | |
| <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> | |
| <script type="text/javascript"> | |
| var c=0 | |
| var t | |
| function timedCount() | |
| { | |
| document.getElementById(‘txt‘).value=c | |
| c=c+1 | |
| t=setTimeout("timedCount()",1000) | |
| } | |
| function stopCount() | |
| { | |
| setTimeout("document.getElementById(‘txt‘).value=0",0); | |
| clearTimeout(t); | |
| } | |
| function restopCount() | |
| { | |
| setTimeout("document.getElementById(‘txt‘).value=c",0); | |
| clearTimeout(t); | |
| } | |
| </script> | |
| </head> | |
| <body> | |
| <form> | |
| <input type="button" value="开始/重新计时!" onClick="timedCount()"> | |
| <input type="button" value="停止计时!" onClick="stopCount()"> | |
| <input type="text" id="txt"> | |
| <input type="button" value="暂停计时!" onClick="restopCount()"> | |
| </form> | |
| </body> | |
| </html> |
使用setTimeout setInterval实现秒表计时器( 开始/暂停 停止计时)
标签:
原文地址:http://www.cnblogs.com/FG123/p/4391201.html