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

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

我的代碼哪里有錯(cuò)呢?我怎么排除都實(shí)現(xiàn)不了。

<!DOCTYPE html>
<html>
<head>
??? <meta charset="UTF-8">
??? <title>more</title>
<style type="text/css">
ul ,li{

?? ?list-style: none;
}
ul li{
width:200px;
height: 100px;
background: yellow;
margin-bottom: 20px;

}


</style>
<script type="text/javascript">
?? ?window.onload=function(){

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

??? for(var i=0;i<Ali.length;i++){
?????? Ali[i].onmouseover=function(){
??????? startMove(this,500);

?????? }

?????? Ali[i].onmouseout=function(){
????? ??? ?startMove(this,10);
?????? }
??? }


?? ?}

var timer=null;
function startMove(obj,iTarget){
clearInterval(timer);
timer=setInterval(function(){
??? var speed=(iTarget-obj.offsetwidth)/10;
??? if(speed=speed>0){ Math.ceil(speed)}
????? else{
???? Math.floor(speed);}
??? 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>

正在回答

2 回答

  1. offsetwidth寫錯(cuò)了,應(yīng)該是offsetWidth;

  2. ?if(speed=speed>0){ ? //這里不太懂為什么要賦值,我改成了(speed>0)

    ?????Math.ceil(speed) ? //這里要賦值,不然計(jì)算了也沒有用到。改成speed=Math.ceil(speed);

    }
    else{
    ???? Math.floor(speed); ? //改成speed=Math.floor(speed);

    }

  3. ?if(obj.offsetwidth=iTarget){ ? ?//這里應(yīng)該是obj.offsetwidth==iTarget,而不是賦值噢
    ? ? ? clearInterval(timer);
    }?else{
    ?? ??? ?obj.style.width=obj.offsetwidth+speed+'px';? }
    ??

  4. 改了這些地方之后應(yīng)該就能動(dòng)了,雖然還有一些BUG,共用了定時(shí)器神馬的,我也還沒消化好。。就只能幫到這里了恩:)

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

雪神仙 提問者

非常感謝
2016-08-09 回復(fù) 有任何疑惑可以回復(fù)我~
<script?type="text/javascript">
??window.onload=function(){
????var?oLi?=?document.getElementsByTagName("li");
????
????for(var?i=0;i<oLi.length;i++){
??????oLi[i].timer=null;??????????//給每一個(gè)li的onmouseover事件設(shè)置一個(gè)定時(shí)器
??????oLi[i].onmouseover=function(){
????????startMove(this,500);
??????};

??????oLi[i].onmouseout=function(){
????????startMove(this,10);
???????};
????}
??}

function?startMove(obj,iTarget){
??clearInterval(obj.timer);
??obj.timer=setInterval(function(){
????var?speed=(iTarget-obj.offsetWidth)/10;?//offsetWidth拼錯(cuò)了,要用駝峰法。
????speed=speed>0???Math.ceil(speed)?:?Math.floor(speed);//你原來這里的if?else語句寫錯(cuò)了,我給你改成了三元表達(dá)式。實(shí)現(xiàn)的作用和樓上那位同學(xué)是一樣的,你原來的代碼你可以自己去alert(speed),是一個(gè)布爾值。
????if(obj.offsetWidth==iTarget){?//if?語句的判斷錯(cuò)了。
??????clearInterval(obj.timer);
????}
????else{
????????obj.style.width=obj.offsetWidth+speed+'px';
????}
??
??},30)
}
</script>


具體的錯(cuò)誤其實(shí)我樓上那位同學(xué)都給你指出來了,你可以對照我的代碼印證一下
0 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消

我的代碼哪里有錯(cuò)呢?我怎么排除都實(shí)現(xiàn)不了。

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

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

幫助反饋 APP下載

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

公眾號(hào)

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