我在script里的function 为按钮加了onclick事件,为什么不能取消计时器
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>计时器</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>