一下代码中,didi函数中的haha为什么不用定义
如题,为什么不定义var haha=。。。
2016-06-24
你这代码是错的呀,停止都没有用好嘛,不点开始自动就开始了,看不懂呀;
haha的作用域只在script标签中呀,你在下面可以掉用到吗?????
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>计时器</title>
<script type="text/javascript">
function clock(){
var time=new Date();
document.getElementById("clock").value = time;
}
var haha;
function didi()
{
haha=setInterval(clock,1000)
}
function stop() {
clearInterval(haha)
}
</script>
</head>
<body>
<form>
<input type="text" id="clock" size="50" onclick="clock()" />
<input type="button" value="Stop" onclick="stop()"/>
<input type="button" value="Start" onclick="didi()"/>
</form>
</body>
</html>举报