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

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

不會動,代碼一樣,就是不會動

<!DOCTYPE html>
<html>
<head>
?? ?<title>huoqu</title>
</head>
<style type="text/css">
?? ?body,ul,li{
?? ??? ?margin: 0;
?? ??? ?padding: 0;
?? ?}
?? ?ul,li{
?? ??? ?list-style: none;

?? ?}
?? ?ul li{
?? ??? ?width: 200px;
?? ??? ?height: 100px;
?? ??? ?background: blue;
?? ??? ?margin-bottom: 20px;
?? ?}
</style>
<script type="text/javascript">
?? ?window.onload=function(){
?? ??? ?var ai=document.getElementsByTagName('li');
?? ??? ?for(var i=0;i<ali.length;i++){
?? ??? ??? ?ai[i].timer=null;
?? ??? ??? ?ai[i].onmouseover=function(){
?? ??? ??? ??? ?starmove(this,400);
?? ??? ??? ?}
?? ??? ??? ?ai[i].onmouseout=function{
?? ??? ??? ??? ?starmove(this,200);
?? ??? ??? ?}
?? ??? ?}
?? ?}
function starmove(obj,target){
?? ?clearInterval(obj.timer);
?? ?obj.timer=setInterval(function(){
?? ??? ?var speed=(target-obj.offsetWidth)/8;
?? ??? ?speed=speed>0?Math.ceil(speed):Math.floor(speed);
?? ??? ?if(obj.offsetWidth==target){
?? ??? ??? ?clearInterval(obj.timer);
?? ??? ?}
?? ??? ?else{
?? ??? ??? ?obj.style.width=obj.offsetWidth+speed+'px';
?? ??? ?}
?? ?},30);
}
</script>
<body>
<ul>
?? ?<li></li>
?? ?<li></li>
?? ?<li></li>
</ul>
</body>
</html>

正在回答

6 回答

ai[i].onmouseout=function(){}少了一個括號 ?好友出現(xiàn)問題 在網(wǎng)頁上右擊檢查元素 ?可以很快發(fā)現(xiàn)問題 望采納

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

http://img1.sycdn.imooc.com//5842ef7c0001080d04450294.jpg

變量寫錯了

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

你說我是慕粉 提問者

已經(jīng)好了Y(^o^)Y,不知道為什么,變量改過來還是錯了,再打一遍就好了Y(^o^)Y,謝謝,晚安
2016-12-04 回復(fù) 有任何疑惑可以回復(fù)我~

我也遇到這樣的問題了!代碼一樣,就是不動。

<!DOCTYPE html>

<html>

<head>

<title></title>

<style type="text/css">

*{margin: 0;padding: 0;}

ul,li{list-style-type: 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,400);

}

aLi[i].onmouseout=function(){

startMove(this,200);

}

}

}

var timer=null;

function startMove(obj,iTarget){

clearInterval(timer);

timer=setInterval(function(){

var speed=(iTarget-obj.offsetWidth)/8;

speed=speed>0?Math.ceil(speed):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>


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

慕粉3126759

setInterval(...,30)后面的冒號沒寫
2016-12-04 回復(fù) 有任何疑惑可以回復(fù)我~
#2

慕仔2791819 回復(fù) 慕粉3126759

謝謝老板!
2016-12-10 回復(fù) 有任何疑惑可以回復(fù)我~

我放你的代碼進(jìn)去編輯器看了,onmouseout是對的,但是他沒有高亮顯示 你重新打一遍就好,不需要糾結(jié)

附上完整代碼

<!DOCTYPE html>

<html>

<head>

? ? <title>huoqu</title>

</head>

<style type="text/css">

? ? body,ul,li{

? ? ? ? margin: 0;

? ? ? ? padding: 0;

? ? }

? ? ul,li{

? ? ? ? list-style: none;


? ? }

? ? ul li{

? ? ? ? width: 200px;

? ? ? ? height: 100px;

? ? ? ? background: blue;

? ? ? ? margin-bottom: 20px;

? ? }

</style>

<script type="text/javascript">

? ? window.onload=function(){

? ? ? ? var ai=document.getElementsByTagName('li');

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

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

? ? ? ? ? ? ai[i].onmouseover=function(){

? ? ? ? ? ? ? ? starmove(this,400);

? ? ? ? ? ? ? ? }

? ? ? ? ? ? ai[i].onmouseout=function(){

? ? ? ? ? ? ? ? starmove(this,200);

? ? ? ? ? ? ? ? }

? ? ? ? ? ? }

? ? ? ??

? ? }

function starmove(obj,target){

? ? clearInterval(obj.timer);

? ? obj.timer=setInterval(function(){

? ? ? ? var speed=(target-obj.offsetWidth)/8;

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

? ? ? ? if(obj.offsetWidth==target){

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

? ? ? ? }

? ? ? ? else{

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

? ? ? ? }

? ? },30);

}

</script>

<body>

<ul>

? ? <li></li>

? ? <li></li>

? ? <li></li>

</ul>

</body>

</html>

望采納,晚安

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

你說我是慕粉 提問者

謝謝,晚安
2016-11-30 回復(fù) 有任何疑惑可以回復(fù)我~
#2

你說我是慕粉 提問者

今天試了,還是不行。。。
2016-11-30 回復(fù) 有任何疑惑可以回復(fù)我~
#3

你說我是慕粉 提問者

今天試了,還是不行。。。
2016-11-30 回復(fù) 有任何疑惑可以回復(fù)我~

那個for循環(huán)那個ali寫錯了,單詞

?var ai=document.getElementsByTagName('li');
?? ??? ?for(var i=0;i<ai.length;i++){
?? ??? ??? ?ai[i].timer=null;
?? ??? ??? ?ai[i].onmouseover=function(){
?? ??? ??? ??? ?starmove(this,400);
?? ??? ??? ?}
?? ??? ??? ?ai[i].onmouseout=function{
?? ??? ??? ??? ?starmove(this,200);
?? ??? ??? ?}
?? ??? ?}

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

你說我是慕粉 提問者

改了,沒用
2016-11-29 回復(fù) 有任何疑惑可以回復(fù)我~

三個li會不會獲取的時候出了問題,你給它們設(shè)個id試試

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

你說我是慕粉 提問者

沒用啊,那個getelmentsbytagname不是獲取標(biāo)簽名嗎?跟這有關(guān)系嗎?
2016-11-29 回復(fù) 有任何疑惑可以回復(fù)我~

舉報

0/150
提交
取消

不會動,代碼一樣,就是不會動

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

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

幫助反饋 APP下載

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

公眾號

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