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

為了賬號安全,請及時綁定郵箱和手機立即綁定

有關oBox[i].timer=null;的 問題?

有關oBox[i].timer=null;的 問題?

55c9b3620001c5fa02910200.jpg

55c9b3620001cfd405000079.jpg

<script>
?? ?window.onload=function(){
?? ?<!--?? ?var timer;-->
?? ??? ?var oBox=document.getElementsByTagName("div");
?? ??? ?for(var i=0;i<=oBox.length;i++){
?? ??? ?oBox[i].timer=null;
?? ??? ?oBox[i].onmouseover=function(){startMove(this,300);};
?? ??? ?oBox[i].onmouseout=function(){startMove(this,0);};
?? ??? ?}
?? ??? ??? ?function startMove(obj,target){
?? ??? ??? ??? ?clearInterval(obj.timer);?? ?
?? ??? ??? ??? ?obj.timer=setInterval(function(){
?? ??? ??? ??? ??? ?var speed=(target-obj.offsetLeft)/10;
?? ??? ??? ??? ??? ?speed=speed>0 ? Math.ceil(speed):Math.floor(speed);?? ?
?? ??? ??? ??? ??? ?if (obj.offsetLeft==target){
?? ??? ??? ??? ??? ??? ?clearInterval(obj.timer);}
?? ??? ??? ??? ??? ?else{
?? ??? ??? ??? ??? ??? ?obj.style.left=obj.offsetLeft+speed+"px";}
?? ??? ??? ??? ??? ?},30);
?? ??? ??? ??? ?};
?? ??? ?};
?? ??? ?
</script>

正在回答

3 回答

length那里應該是

for(var?i?=?0?;?i?<?oBox.length?;?i?++){}

其次是下面的offsetLeft 應該改成 offsetWidth

0 回復 有任何疑惑可以回復我~

?for(var i=0;i<=oBox.length;i++) ?這里取不到length,是<length

0 回復 有任何疑惑可以回復我~

for里面判斷條件的=去掉試下

0 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消
JS動畫效果
  • 參與學習       113918    人
  • 解答問題       1502    個

通過本課程JS動畫的學習,從簡單動畫開始,逐步深入各種動畫框架封裝

進入課程

有關oBox[i].timer=null;的 問題?

我要回答 關注問題
微信客服

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

幫助反饋 APP下載

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

公眾號

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