计时器程序无法停止计时
写了好多遍,都是能开始就停不了,能停就不能开始,我希望能实现点击start按钮,text框(初始为null)开始计时,点击stop,计时结束。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script type="text/javascript">
function gg_1(){
var s=new Date();
document.getElementById("time").value=s;
}
var i=setInterval(gg_1,100);
function ss(){
clearInterval(i);
}
</script>
</head>
<body>
<input type="button" id="start" value="Start" onclick="gg_1()"/>
<input type="text" id="time" />
<input type="button" id="stop" value="Stop" onclick="ss()"/>
</body>
</html>