我div的節(jié)點(diǎn)會(huì)出現(xiàn)收不回去的bug,而且還會(huì)來(lái)回運(yùn)動(dòng)<!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>無(wú)標(biāo)題文檔</title><style type="text/css">div,span,body{ margin:0px; padding:0px; }#div1{width:200px;height:200px;background:#03F;position:relative;left:-200px;top:0px}#div1 span{width:20px;height:50px;background:#CCC;position:absolute;left:200px;top:75px}</style><script type="text/javascript">window.onload=function(){ var D=document.getElementById("div1");? ? D.onmouseover=function(){ M(0); } D.onmouseout=function(){ M(-200); } function M(T){ var D=document.getElementById("div1"); var timer=null; clearInterval(timer);? ? ? timer =setInterval(function(){ var s=0; if(T>D.offsetLeft){ s=10; } else{ s=-10; } if(T==D.offsetLeft){ clearInterval(timer); } else{ D.style.left=D.offsetLeft+s+"px"; } },30) }}</script></head><body><div id="div1"><span></span><div></body></html>
求大神知道如何解決這段代碼的bug
健C
2016-07-26 21:17:26