为什么stop没有用??
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<form>
<input type="text" id="text" />
<input type="button" value="start" onclick="timer()" />
<input type="button" value="stop" onclick="clear()" />
</form>
</body>
</html>
<script>
var num=0;
var i;
function timer(){
document.getElementById("text").value=num;
num+=1;
i=setTimeout("timer()",2000);
}
//setTimeout("timer()",2000);
function clear(){
clearTimeout(i);
}
</script>