| |
window.clearTimeout():
功能:取消由setTimeout()方法设置的定时器。 语法:clearTimeout(id_of_settimeout) 参数:
|
带停表功能的秒计时器。
- <script type="text/javascript">
- var count = 0;
- var timeID;
- function timeCount()
- {
- document.getElementById('timetxt').value = count;
- count++;
- timeID = setTimeout("timeCount()",1000);
- }
- function stopCount()
- {
- clearTimeout(timeID);
- }
- </script>
- <input type="button" value="开始计时" />
- <input type="text" id="timetxt" size="5" />
- <input type="button" value="停止计时" />
转载于:https://blog.51cto.com/geyulong/783486