亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

鼠標已開div返回原來位置一直抖動,有時候不能回到原位,不知道為什么,求大神解答

鼠標已開div返回原來位置一直抖動,有時候不能回到原位,不知道為什么,求大神解答

張筱諾8983 2015-12-05 23:25:41
<!DOCTYPE html><charset="UTF-8"><html><head> <title>yundong</title> <style> body,div,span{ margin: 0; padding: 0; } #div1{ height: 200px; width: 200px; position: relative; top: 0; left: -200px; background-color:red;? ? opacity: 0.7; } #share{ height: 50x; width: 20px; position: absolute; left: 200px; top: 75px; background-color:blue;? ? opacity: 0.9; } </style></head><body><div id="div1"> <span id="share">分享</span></div><script type="text/javascript">? ?window.onload=function(){ var oDIV=document.getElementById("div1"); oDIV.onmouseover=function(){ onMove(); } oDIV.onmouseout=function(){ stopMove(); } } function onMove(){ clearInterval(timer); var oDIV=document.getElementById("div1"); var timer=null; timer=setInterval(function(){ ? ?if (oDIV.offsetLeft==0) { clearInterval(timer); } else{? ? ? ? ? ? oDIV.style.left=oDIV.offsetLeft+10+"px"; ? ?} },30) } function stopMove(){ clearInterval(timer); var oDIV=document.getElementById("div1"); var timer=null; timer=setInterval(function(){ ? ?if (oDIV.offsetLeft==-200) { clearInterval(timer); } else{? ? ? ? ? ? oDIV.style.left=oDIV.offsetLeft-10+"px"; ? ?} },30) }</script></body></html>
查看完整描述

1 回答

  • 1 回答
  • 0 關注
  • 1879 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號