<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
</head>
<body>
<div id="we" style="width:100px; height:100px; position:absolute; top:0; left:0; background:red;"></div>
<br/><br/><br/><br/><br/><br/><br/>
<input type="button" value="点击A" onclick="showA()"/>
<input type="button" value="点击B" onclick="showB()"/>
</body>
<script type="text/javascript">
var a=0;
function move(){
a=a+30;
document.getElementById('we').style.left=a+'px';
}
function showA(){
timer=window.setInterval('move()',200);
}
function showB(){
window.clearInterval(timer);
}
</script>
</html>
timer=setInterva在showA()这个函数里,
window.clearInterval在showB这个函数里,
点击showA(),div盒子开始滑动,
为什么点击showB可以令showA里的timer停止?