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

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

每次按照老師的,一樣寫都運(yùn)行不出來(lái),大神們幫幫忙

<!DOCTYPE?html>
<html?lang="en">
<head>
????<meta?charset="UTF-8">
????<title>Title</title>
????<style?type="text/css">
?*{padding:0;margin:0;}
????????ul,li{list-styleLnone;}
????????ul?li{
????????????width:200px;
?height:100px;
?line-height:100px;
?background:yellow;
?margin-bottom:20px;
?}
????</style>
????<script?>
?window.onload=function()//網(wǎng)頁(yè)剛打開(kāi)的就時(shí)候執(zhí)行函數(shù)
?{
???????????var?aLi=document.getElementById("li");
?for(var?i=0;i<aLi.length;i++)
???????????{
???????????????aLi[i].onmouseover=function()//鼠標(biāo)移上去的時(shí)候執(zhí)行函數(shù)function
?{
???????????????????startMove(this,400);//參數(shù)1?開(kāi)始運(yùn)動(dòng)到400這個(gè)位置
?}
???????????????aLi[i].onmouseover=function()
???????????????{
???????????????????startMove(this,200);//參數(shù)2?返回運(yùn)動(dòng)到200這個(gè)位置
?}
???????????}
????????}
????????var?timer?=?null;
?function?startMove(obj,iTarget)//前面有兩個(gè)參數(shù),這里也要寫兩個(gè)參數(shù)
?{
???????????clearInterval(timer);//關(guān)閉定時(shí)器
?timer?=?setInterval(function()
???????????{???????????????????????????/*對(duì)象的可見(jiàn)寬度*/??????//即距離
?var?speed?=(iTarget-obj.offsetWidth)/8;//速度=(目標(biāo)值-東西的寬度)/時(shí)間
?speed?=?speed?>0?Math.ceil(speed):Math.floor(speed);
?//速度=速度>0那么向上取整:否則向下取整;
?if(obj.offsetWidth?==?iTarget)
???????????????{
???????????????????clearInterval(timer);
?}
???????????????else
?{
???????????????????obj.style.width?=?obj.offsetWidth?+?speed?+?'px';
?}
???????????},30)
???????}
????</script>
</head>
<body>
<ul>
????<li></li>
????<li></li>
????<li></li>
</ul>

</body>
</html>


正在回答

4 回答

<!DOCTYPE html>

<html>

<head>

? ? <meta charset="UTF-8">

? ? <title>Title</title>

? ? <style type="text/css">

?*{padding:0;margin:0;}

? ? ? ? ul,li{list-style:none;}

? ? ? ? ul li{

? ? ? ? ? ? width:200px;

?height:100px;

?line-height:100px;

?background:yellow;

?margin-bottom:20px;

?}

? ? </style>

? ? <script >

?window.onload=function()//網(wǎng)頁(yè)剛打開(kāi)的就時(shí)候執(zhí)行函數(shù)

?{

? ? ? ? ? ?var aLi=document.getElementsByTagName("li");

?for(var i=0;i<aLi.length;i++)

? ? ? ? ? ?{

? ? ? ? ? ? aLi[i].timer=null;

? ? ? ? ? ? ? ?aLi[i].onmouseover=function()//鼠標(biāo)移上去的時(shí)候執(zhí)行函數(shù)function

?{

? ? ? ? ? ? ? ? ? ?startMove(this,400);//參數(shù)1 開(kāi)始運(yùn)動(dòng)到400這個(gè)位置

?}

? ? ? ? ? ? ? ?aLi[i].onmouseout=function()

? ? ? ? ? ? ? ?{

? ? ? ? ? ? ? ? ? ?startMove(this,200);//參數(shù)2 返回運(yùn)動(dòng)到200這個(gè)位置

?}

? ? ? ? ? ?}

? ? ? ? }

? ? ? ? // var timer = null;

?function startMove(obj,iTarget)//前面有兩個(gè)參數(shù),這里也要寫兩個(gè)參數(shù)

?{

? ? ? ? ? ?clearInterval(obj.timer);//關(guān)閉定時(shí)器

?obj.timer = setInterval(function()

? ? ? ? ? ?{? ? ? ? ? ? ? ? ? ? ? ? ? ?/*對(duì)象的可見(jiàn)寬度*/? ? ? //即距離

?var speed =(iTarget-obj.offsetWidth)/8;//速度=(目標(biāo)值-東西的寬度)/時(shí)間

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

?//速度=速度>0那么向上取整:否則向下取整;

?if(obj.offsetWidth == iTarget)

? ? ? ? ? ? ? ?{

? ? ? ? ? ? ? ? ? ?clearInterval(obj.timer);

?}

? ? ? ? ? ? ? ?else

?{

? ? ? ? ? ? ? ? ? ?obj.style.width = obj.offsetWidth + speed + 'px';

?}

? ? ? ? ? ?},30);

? ? ? ?}

? ? </script>

</head>

<body>

<ul>

? ? <li></li>

? ? <li></li>

? ? <li></li>

</ul>


</body>

</html>


0 回復(fù) 有任何疑惑可以回復(fù)我~
if(obj.offsetWidth?==?iTarget)

if判斷句應(yīng)該是2個(gè)==號(hào)

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

https://img1.sycdn.imooc.com//5b3cec48000119ac06750201.jpg 這樣應(yīng)該可以吧

0 回復(fù) 有任何疑惑可以回復(fù)我~
?var?aLi=document.getElementById("li");?這里li是標(biāo)簽名啊,
?應(yīng)該是var?aLi=document.getElementsByTagName('li');注意一下這個(gè)aLi是一個(gè)數(shù)組。
?var?timer?=?null;還有這里,老師演示的時(shí)候不是給每個(gè)方塊都分配一個(gè)timer嗎?aLi[i].timer=null;相應(yīng)的startMove方法里面也要改一下。
0 回復(fù) 有任何疑惑可以回復(fù)我~
#1

夜闌臥聽(tīng)風(fēng)吹雨y 提問(wèn)者

改了,還是運(yùn)行不了,沒(méi)用
2018-06-27 回復(fù) 有任何疑惑可以回復(fù)我~
#2

Sapce 回復(fù) 夜闌臥聽(tīng)風(fēng)吹雨y 提問(wèn)者

1. 是getElementsByTagName(); Elements 不是 Element 2. 一個(gè)是 onmouseover(), 一個(gè)是 onmouseout; over 和 out 3. css 樣式中 ul,li { } 中有誤,請(qǐng)仔細(xì)檢查下哦
2018-07-07 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

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

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

進(jìn)入課程

每次按照老師的,一樣寫都運(yùn)行不出來(lái),大神們幫幫忙

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

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

幫助反饋 APP下載

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

公眾號(hào)

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