我在script里的function 為按鈕加了onclick事件,為什么不能取消計(jì)時(shí)器
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>計(jì)時(shí)器</title>
<script type="text/javascript">
? var i=setInterval("clock()",1000);
?? function clock(){
????? var time=new Date();????????????? ??? ? ?
????? document.getElementById("clock").value = time;
????? var butt=document.getElementById("but");
????? butt.onclick()=function(i){
????????? clearInterval(i);
????? }
?? }??? ?
</script>
</head>
<body>
? <form>
??? <input type="text" id="clock" size="50"? />
??? <input type="button" value="Stop" id="but"/>
? </form>
</body>
</html>
2016-06-07
butt.onclick()=function(){????多了個(gè)括號(hào),不用傳參進(jìn)去---------------- ?butt.onclick=function(){}
????????? clearInterval(i);
????? }
2016-05-31
onclick=""這樣才行。