第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時(shí)綁定郵箱和手機(jī)立即綁定

問一下哪里錯(cuò)了

<!DOCTYPE html>

<html>

<head>

<script ?src="http://libs.baidu.com/jquery/1.9.1/jquery.js"></script>

<meta charset="UTF-8">

<title>JS緩沖動(dòng)畫</title>

<style type="text/css">


body,ul,ol,li,p,h1,h2,h3,h4,h5,h6,form,fieldset,table,td,img,div,dl,dt,

dd,input{margin:0;padding:0;}

body{font-size:12px;}

img{border:none;}

li{list-style:none;}

input,select,textarea{outline:none;}

textarea{resize:none;}

#div1{

height: 200px;

width: 200px;

background-color: red;

position: relative;

left: -200px;

top: 0;

}


#div1 span{

background-color: blue;

width:20px;

height: 50px;

position: absolute;

left: 200px;

top: 75px;

}




</style>



<script type="text/javascript">

window.onload=function(){

var oDiv=document.getElementById('div1');

oDiv.onmouseover=function(){

startMove(0);

}

oDiv.onmouseout=function(){

startMove(-200);

}

}

var timer=null;

function startMove(iTarget) {

clearInterval(timer);

var oDiv=document.getElementById('div1');

var speed=(iTarget-oDiv.offsetLeft)/30;

speed = speed>0?Math.ceil(speed):Math.floor(speed);

timer=setInterval(function(){

if(oDiv.offsetLeft==iTarget){

clearInterval(timer);

}

else{


oDiv.style.left=oDiv.offsetLeft+speed+'px';


}

},30)

}




</script> ?





</head>

<body>



<script type="text/javascript">




</script>


<div id="div1" ><span id="share">分享</span></div>

</body>

</html>


正在回答

3 回答

你把那些定義speed 的內(nèi)容放在setInterval()里面試一試

0 回復(fù) 有任何疑惑可以回復(fù)我~
#1

ASDDSAFAS 提問者

我試了試可以,但不知道為什么,麻煩解釋一下,謝謝
2017-07-06 回復(fù) 有任何疑惑可以回復(fù)我~

不定義里面怎么循環(huán)

0 回復(fù) 有任何疑惑可以回復(fù)我~

定義在外面相當(dāng)于一個(gè)值,定義在里面才能循環(huán)。

0 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消
JS動(dòng)畫效果
  • 參與學(xué)習(xí)       113920    人
  • 解答問題       1487    個(gè)

通過本課程JS動(dòng)畫的學(xué)習(xí),從簡單動(dòng)畫開始,逐步深入各種動(dòng)畫框架封裝

進(jìn)入課程

問一下哪里錯(cuò)了

我要回答 關(guān)注問題
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號