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

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

請(qǐng)問下各位大神,這段js代碼如何理解?圖片的漸隱漸現(xiàn)。

請(qǐng)問下各位大神,這段js代碼如何理解?圖片的漸隱漸現(xiàn)。

天空雨了 2016-07-03 16:07:03
<!DOCTYPE?html?PUBLIC?"-//W3C//DTD?XHTML?1.0?Transitional//EN"?"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html?xmlns="http://www.w3.org/1999/xhtml"> <head> <meta?http-equiv="Content-Type"?content="text/html;?charset=utf-8"?/> <title>js漸隱漸現(xiàn)圖片切換效果</title> <style?type="text/css"> *{margin:0;padding:0;list-style-type:none;} a,img{border:0;} body{font:12px/180%?Arial,?Helvetica,?sans-serif,?"新宋體";} /*?focus?*/ #focus{width:380px;height:504px;margin:0?auto;} #focus?div{position:absolute;width:380px;height:504px;overflow:hidden;} #focus?img{width:380px;height:504px;} #focus?#focus_img{display:none;} </style> </head> <body> ????<div?id="focus"> ????????<div?id="focus_bg"></div> ????????<div?id="focus_show"></div> ????????<div?id="focus_img"> ????????????<div?name="focus_img"?id="focus_1">images/asdfw580.jpg|http://sc.chinaz.com/|美女1號(hào)</div> ????????????<div?name="focus_img"?id="focus_2">images/sfw580.jpg|http://sc.chinaz.com/|美女2號(hào)</div> ????????</div> ????????<script?type="text/javascript"> ????????????var?focus_id?=?1; ????????????var?focus_time?=?0; ????????????var?focus_bg?=?""; ????????????var?focus_begin?=?true; ????????????var?focus_interval; ????????????var?focus_count; ????????????var?focus_url?=?""; ????????????var?focus_title?=?""; ????????????if(navigator.appName?==?"Microsoft?Internet?Explorer") ????????????{ ????????????????focus_count?=?document.getElementById("focus_img").childNodes.length; ????????????}else{ ????????????????focus_count?=?document.getElementsByName("focus_img").length; ????????????} ????????????function?func_focus() ????????????{ ????????????????if(focus_id?>?focus_count)?focus_id?=?1; ????????????????if(!focus_begin)?clearInterval(focus_interval); ????????????????focus_interval?=?setInterval("focus_show("?+?focus_id?+?")",50); ????????????} ????????????function?focus_show(id) ????????????{ ????????????????if(focus_time?<?20?&&?focus_bg?!=?"") ????????????????{ ????????????????????var?v?=?100?/?20; ????????????????????if(navigator.appName=="Microsoft?Internet?Explorer") ????????????????????{ ????????????????????????document.getElementById("focus_show").style.filter?=?"Alpha(Opacity="?+?(v?*?focus_time)?+?")"; ????????????????????}else{ ????????????????????????document.getElementById("focus_show").style.opacity?=?v?*?focus_time?/?100; ????????????????????} ????????????????????focus_time?++; ????????????????}else?if(focus_count?>?0){ ????????????????????if(!focus_begin) ????????????????????{ ????????????????????????document.getElementById("focus_bg").innerHTML?=?"<img?src='"?+?focus_bg?+?"'?/>"; ????????????????????????focus_time?=?0; ????????????????????????clearInterval(focus_interval); ????????????????????} ????????????????????var?val?=?document.getElementById("focus_"?+?focus_id).innerHTML; ????????????????????var?arr?=?val.split("|"); ????????????????????if(navigator.appName=="Microsoft?Internet?Explorer") ????????????????????{ ????????????????????????document.getElementById("focus_show").style.filter?=?"Alpha(Opacity=0)"; ????????????????????}else{ ????????????????????????document.getElementById("focus_show").style.opacity?=?0; ????????????????????} ????????????????????document.getElementById("focus_show").innerHTML?=?"<a?href='"?+?focus_url?+?"'?target='_blank'?title='"?+?focus_title?+?"'><img?src='"?+?arr[0]?+?"'?/></a>"; ????????????????????focus_url?=?arr[1]; ????????????????????focus_title?=?arr[2]; ????????????????????if(focus_count?>?1)?focus_id?++; ????????????????????if(!focus_begin)?focus_interval?=?setInterval("func_focus()",3000);?else?focus_begin?=?false; ????????????????????focus_bg?=?arr[0]; ????????????????} ????????????} ????????????func_focus(); ????????</script> ????</div><!--focus?end--> </body> </html>
查看完整描述

1 回答

?
漢娜之眼

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


這個(gè)使用定時(shí)器實(shí)現(xiàn)的,跟你說(shuō)一下思路吧,你給的代碼感覺比較麻煩。

  1. 定義div設(shè)置導(dǎo)入img并定好id

  2. 編寫js代碼,定義函數(shù)為img透明度增減

  3. 設(shè)置定時(shí)器循環(huán)調(diào)用js的透明度變化函數(shù)

    這樣就實(shí)現(xiàn)了圖片漸隱漸現(xiàn),其實(shí)就是定時(shí)器循環(huán)改變透明度而已。

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

添加回答

舉報(bào)

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號(hào)

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