先谢谢大神啦!!<style type="text/css"> *{margin:0;padding:0;} #d1{ width:200px; height:100px; background-color:#0f3; position:relative; left:-200px; } #d1 span{ width:25px; height:50px; background:yellow; position:absolute; right:-23px; top:50px; display:block; } </style><script > window.onload=function(){ var oid=document.getElementyById('d1'); oid.onmouseover=function(){ startmove(0); } oid.onmouseout=function(){ startmove(-200); } } var timer=null; function.startmove(offsetleft){ clearInterval(timer); timer=setInterval(function(){ var speed=0; var oid=document.getElementById('d1'); if(oid.offsetLeft>offsetleft){ speed=10; } else{ clearInterval(timer); }oid.style.left=oid.offsetLeft+speed+'px'; },30); }</script><div id="d1"><span>分享</span></div>
1 回答
引晴上初
TA贡献6条经验 获得超6个赞
最主要错误就是
if(oid.offsetLeft>offsetleft){
speed=10;
}
应该是<
function.startmove(offsetleft){
多了.
添加回答
举报
0/150
提交
取消