為什么我的代碼沒有用
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>計時器</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>
2018-12-25
函數調用的不對
<input type="text" id="count" />
? ? <input type="button" value="Start" onclick="startCount()" />
? ? <input type="button" value="Stop" onclick="stopCount()"? />
2018-12-12
把script標簽及其內容放在input(id是text)標簽之后.因為,html文件加載有順序,先是head后是body.(......后面省略200字)
2018-11-27
函數一定不要丟掉了后面的括號,因為有的時候括號里面是需要參數的,也不一定是個函數就有參數,但是startCount()這樣寫才是一個完整的函數。。所有onclick調函數的時候加上括號就可以了。。
2018-11-27
下面的onclick調用函數時記得加()雙括號,你加上括號在試一下。。