为什么这段代码不能让计时器停下??
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>滚动</title> <style type="text/css"> *{margin: 0px;padding: 0px;} #box{margin: 0px auto;} ul{list-style: none;} li{margin-left: 20px;height: 25px;line-height: 25px;} #box{width: 200px;height: 200px;overflow: hidden;border: 1px solid red} </style> </head> <body> <div id="box"> <ul id="can1"> <li>第一名</li> <li>第er名</li> <li>第三名</li> <li>第四名</li> <li>第五名</li> <li>第六名</li> <li>第七名</li> <li>第八名</li> <li>第九名</li> <li>第shi名</li> <li>第十一名</li> </ul> <ul id="can2"></ul> </div> <script> var oBox = document.getElementById('box'); var canone = document.getElementById('can1'); var cantwo = document.getElementById('can2'); oBox.scrollTop = 0; cantwo.innerHTML = canone.innerHTML; function Move(){ if (oBox.scrollTop >= canone.scrollHeight) { oBox.scrollTop = 0; }else{ oBox.scrollTop++; } } var timer = setInterval('Move()',50); oBox.onmouseover = function(){ clearInterval(timer); } oBox.onmouseout = function(){ setInterval('Move()',50); } </script> </body> </html>
上边是我的代码。。当鼠标指针移入的时候,滚动不停止,并且在box里面晃动鼠标,滚动速度加快了