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

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

每次按照老師的,一樣寫都運行不出來,大神們幫幫忙

<!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)頁剛打開的就時候執(zhí)行函數(shù)
?{
???????????var?aLi=document.getElementById("li");
?for(var?i=0;i<aLi.length;i++)
???????????{
???????????????aLi[i].onmouseover=function()//鼠標移上去的時候執(zhí)行函數(shù)function
?{
???????????????????startMove(this,400);//參數(shù)1?開始運動到400這個位置
?}
???????????????aLi[i].onmouseover=function()
???????????????{
???????????????????startMove(this,200);//參數(shù)2?返回運動到200這個位置
?}
???????????}
????????}
????????var?timer?=?null;
?function?startMove(obj,iTarget)//前面有兩個參數(shù),這里也要寫兩個參數(shù)
?{
???????????clearInterval(timer);//關(guān)閉定時器
?timer?=?setInterval(function()
???????????{???????????????????????????/*對象的可見寬度*/??????//即距離
?var?speed?=(iTarget-obj.offsetWidth)/8;//速度=(目標值-東西的寬度)/時間
?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)頁剛打開的就時候執(zhí)行函數(shù)

?{

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

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

? ? ? ? ? ?{

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

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

?{

? ? ? ? ? ? ? ? ? ?startMove(this,400);//參數(shù)1 開始運動到400這個位置

?}

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

? ? ? ? ? ? ? ?{

? ? ? ? ? ? ? ? ? ?startMove(this,200);//參數(shù)2 返回運動到200這個位置

?}

? ? ? ? ? ?}

? ? ? ? }

? ? ? ? // var timer = null;

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

?{

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

?obj.timer = setInterval(function()

? ? ? ? ? ?{? ? ? ? ? ? ? ? ? ? ? ? ? ?/*對象的可見寬度*/? ? ? //即距離

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

?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個==號

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

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

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

夜闌臥聽風(fēng)吹雨y 提問者

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

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

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

舉報

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

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

進入課程

每次按照老師的,一樣寫都運行不出來,大神們幫幫忙

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

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

幫助反饋 APP下載

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

公眾號

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