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

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

js多物體運動中的問題

js多物體運動中的問題

前端小學生a 2017-05-23 17:03:58
<!DOCTYPE html><html><head><meta charset="UTF-8"><title>多物體運動</title><style>*{margin:0;padding:0;}div{width:200px;height:100px;background:#abc;margin-bottom: 20px;}</style></head><body><div></div><div></div><div></div><script>window.onload = function(){var iDiv = document.getElementsByTagName("div");for(var i = 0 ;i < iDiv.length;i++){iDiv[i].onmouseover = function(){startMove(this,400);};iDiv[i].onmouseout = function(){startMove(this,200);};}};function startMove(obj,destination){clearInterval(obj.timer);? ? //將此處改為 obj.timer = null;為什么運行之后在為到達目的地時候鼠標移除div會抽搐obj.timer = setInterval(function(){var speed = (destination - obj.offsetWidth)/8;speed = speed > 0 ? Math.ceil(speed) : Math.floor(speed);if(destination == obj.offsetWidth){clearInterval(obj.timer);}else{obj.style.width = obj.offsetWidth + speed +"px";}?},30);}</script></body></html>
查看完整描述

目前暫無任何回答

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

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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