<form>表單里面<button>和<input type="button">在onclick上面有區別嗎,為什么這里面用<button>調用onclick時候達不到計時的效果???
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>計時器</title>
<script type="text/javascript">
? var num=0;
? function startCount() {
??? document.getElementById('count').value=num;
??? num=num+1; ?
?? setTimeout("startCount()",1000);
? }
?? ?
?
</script>
</head>
<body>
<form>
<input type="text" id="count"? />
<button onclick="startCount()">開始</button>
<!--<input type="button" value="開始" onclick="startCount()"/>-->
</form>
</body>
</html>
2017-09-06
你是不是在慕課網在運行的!你要在開發工具上運行就不會有錯,或者其他!我試過了,你代碼沒問題??梢赃\行,會計數。至于區別,沒啥區別只是格式不一樣而已,功能一樣