案例:JavaScript案例     状态:可编辑再运行    进入横版
x
<p>请点击上面的“开始计时”按钮来启动计时器。输入框会一直进行计时,从 0 开始。点击“停止计时”按钮可以终止计时,并将计数重置为 0。</p>
 
1
<html>
2
<head>
3
<script type="text/javascript">
4
var c=0
5
var t
6
function timedCount()
7
{
8
document.getElementById('txt').value=c
9
c=c+1
10
t=setTimeout("timedCount()",1000)
11
}
12
13
function stopCount()
14
{
15
c=0;
16
setTimeout("document.getElementById('txt').value=0",0);
17
clearTimeout(t);
18
}
19
</script>
20
</head>
21
22
<body>
23
24
<form>

 运行结果 
 北美留学生论坛