我并沒(méi)有點(diǎn)start 只要運(yùn)行就會(huì)增加 而且點(diǎn)stop也沒(méi)有用
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>計(jì)時(shí)器</title>
<script type="text/javascript">
? var num=0;
? var i;
? function startCount(){
? ? document.getElementById('count').value=num;
? ? num=num+1;
? ? i=setTimeout("startCount()",1000);
? }
? setTimeout("startCount()",1000);
? function stopCount(){
? clearTimeout(i);
? }
</script>
</head>
<body>
? <form>
? ? <input type="text" id="count" />
? ? <input type="button" value="Start"? Click="startCount"/>
? ? <input type="button" value="Stop"? Click="stopCount" />
? </form>
</body>
</html>
2020-08-02
成功持行的代碼:
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>計(jì)時(shí)器</title>
<script type="text/javascript">
? var num=0;
? var i;
? function startCount(){
? ? document.getElementById('count').value=num;
? ? num=num+1;
? ? i=setTimeout("startCount()",1000);
? }
? function stopCount(){
? ? clearTimeout(i);
? }
</script>
</head>
<body>
? <form>
? ? <input type="text" id="count" />
? ? <input type="button" value="Start" onclick="startCount()" />
? ? <input type="button" value="Stop" onclick="stopCount()"? />
? </form>
</body>
</html>
2020-04-20
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>計(jì)時(shí)器</title>
<script type="text/javascript">
? var num=0;
? var i;
? function startCount(){
? ? document.getElementById('count').value=num;
? ? num=num+1;
? ? i=setTimeout("startCount()",1000);
? }
? function stopCount(i){
? ? clearTimeout(i);
? }
</script>
</head>
<body>
? <form>
? ? <input type="text" id="count" />
? ? <input type="button" value="Start" onclick="startCount()" />
? ? <input type="button" value="Stop" onclick="stopCount(i)"? />
? </form>
</body>
</html>
2020-03-13
你點(diǎn)擊事件都寫(xiě)錯(cuò)了,計(jì)時(shí)器多寫(xiě)了一個(gè)
2020-02-23
你startCount()函數(shù)下面有一條觸發(fā)語(yǔ)句? ? ?setTimeout("startCount()",1000);?