<!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=gb2312" /> <title>无标题文档</title> <style type="text/css"> *{margin:0;padding:0;} #fuck{ top=0; width:200px; height:200px; background:#00FFFF; position:relative; left:-200px; } #share{ width: 20px; height: 50px; background: blue; position: absolute; left: 200px; top:75px; } </style> </head> <body> <script> window.onload=function(){ var fuck=document.getElementById("fuck"); fuck.onmouseover=function(){ outmove(); } fuck.onmouseout=function(){ inmove(); } } var timer= null; function outmove(){ var fuck=document.getElementById("fuck"); clearInterval(timer); timer=setInterval(function(){ if(fuck.offsetLeft==0){ clearInterval(timer); }else{ fuck.style.left=fuck.offsetLeft+10+"px"; } },30); } function inmove(){ var fuck=document.getElementById("fuck"); clearInterval(timer); timer= setInterval(function(){ if(fuck.offLeft==-200){ clearInterval(timer); }else{ fuck.style.left=fuck.offsetLeft-10+"px"; } },30) } </script> <div id="fuck"> <span id="share">分享</span> </div> </body> </html>为什么鼠标离开后图片就直接缩进去了,连“分享”图片都缩进去了?为嘛?
55行,if(fuck.offLeft==-200){,offsetLeft漏拼