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

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

setTimeout 失效 setTimeout和setInterval 同時(shí)存在

setTimeout 失效 setTimeout和setInterval 同時(shí)存在

GatsbyJh 2016-12-11 16:17:03
<!DOCTYPE?html> <html> <head> ????<meta?charset="UTF-8"> ????<title>music3.0</title> ????<link?rel="stylesheet"?href="css/reset.css"> ????<link?rel="stylesheet"?href="css/main.css"> ????<link?rel="stylesheet"?href="css/index.css"> </head> <body> ????<div> ????????<div></div> ????????<div></div> ????</div> ????<div?class="content?center"> ????????<div> ????????????<div?id="title"> ????????????????<ul> ????????????????????<li><a?href="#">第1</a></li> ????????????????????<li><a?href="#">第2</a></li> ????????????????????<li><a?href="#">第3</a></li> ????????????????????<li><a?href="#">第4</a></li> ????????????????????<li><a?href="#">第5</a></li> ????????????????</ul> ????????????</div> ????????????<div?id="cont"> ????????????????<div> ????????????????????<img?src="img/1?(1).webp"?alt=""> ????????????????</div> ????????????????<div> ????????????????????<img?src="img/1?(2).webp"?alt=""> ????????????????</div> ????????????????<div> ????????????????????<img?src="img/1?(3).webp"?alt=""> ????????????????</div> ????????????????<div> ????????????????????<img?src="img/1?(4).webp"?alt=""> ????????????????</div> ????????????????<div> ????????????????????<img?src="img/1?(5).webp"?alt=""> ????????????????</div> ????????????</div> ????????</div> ????</div> ????<div></div> <script?src="js/script.js"></script> </body> </html> function?$(id){ ????return?typeof?id==='string'?document.getElementById(id):id; } window.onload=function(){ ????var?timer=null; ????var?timer2=null; ????var?index=0; ????//獲取鼠標(biāo)滑過或點(diǎn)擊的標(biāo)簽和要切換內(nèi)容的元素 ????var?lis=$('title').getElementsByTagName('li'), ????????divs=$('cont').getElementsByTagName('div'); ????if(lis.length!=divs.length) ????return; ????//遍歷title下的所有l(wèi)i ????for(i=0;i<lis.length;i++){ ????????lis[i].id=i; ????????lis[i].onmouseover=function(){ ????????????clearInterval(timer2); ????????????//用that來引用當(dāng)前的li ????????????var?that=this; ????????????//如果存在定時(shí)器,就清除定時(shí)器 ????????????if(timer){ ????????????????clearTimeout(timer); ????????????????timer=null; ????????????} ????????????timer=setTimeout(changeOption(that.id),500) ????????} ????????lis[i].onmouseout=function(){ ????????????timer2=setInterval(autoPlay,2000); ????????} ????} ????//定時(shí)器,定時(shí)改變 ????if(timer2){ ????????clearInterval(timer2); ????????timer2=null; ????} ????timer2=setInterval(autoPlay,2000); ????//封裝 ????function?changeOption(x){ ????????????????//清除所有l(wèi)i上的active ????????????????????for(j=0;j<lis.length;j++){ ????????????????????????lis[j].className=''; ????????????????????????divs[j].style.display='none'; ????????????????????} ????????????????//設(shè)置當(dāng)前高亮顯示 ????????????????????lis[x].className='active'; ????????????????????divs[x].style.display='block'; ????????????????????index=x; ????} ????function?autoPlay(){ ????????????index++; ????????????if(index>=lis.length){ ????????????????index=0;} ????????????changeOption(index); ????????} }
查看完整描述

1 回答

?
其實(shí)我真的不是東北人

TA貢獻(xiàn)105條經(jīng)驗(yàn) 獲得超66個(gè)贊

你要粘貼就全部粘貼,留意半成品這里,又看不到效果。

查看完整回答
反對(duì) 回復(fù) 2016-12-11
  • 1 回答
  • 0 關(guān)注
  • 1959 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號(hào)

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