做爰高潮a片〈毛片〉,尤物av天堂一区二区在线观看,一本久久A久久精品VR综合,添女人荫蒂全部过程av

最新文章專題視頻專題問答1問答10問答100問答1000問答2000關(guān)鍵字專題1關(guān)鍵字專題50關(guān)鍵字專題500關(guān)鍵字專題1500TAG最新視頻文章推薦1 推薦3 推薦5 推薦7 推薦9 推薦11 推薦13 推薦15 推薦17 推薦19 推薦21 推薦23 推薦25 推薦27 推薦29 推薦31 推薦33 推薦35 推薦37視頻文章20視頻文章30視頻文章40視頻文章50視頻文章60 視頻文章70視頻文章80視頻文章90視頻文章100視頻文章120視頻文章140 視頻2關(guān)鍵字專題關(guān)鍵字專題tag2tag3文章專題文章專題2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章專題3
問答文章1 問答文章501 問答文章1001 問答文章1501 問答文章2001 問答文章2501 問答文章3001 問答文章3501 問答文章4001 問答文章4501 問答文章5001 問答文章5501 問答文章6001 問答文章6501 問答文章7001 問答文章7501 問答文章8001 問答文章8501 問答文章9001 問答文章9501
當(dāng)前位置: 首頁(yè) - 科技 - 知識(shí)百科 - 正文

js實(shí)現(xiàn)輪播圖的兩種方式(構(gòu)造函數(shù)、面向?qū)ο?

來(lái)源:懂視網(wǎng) 責(zé)編:小OO 時(shí)間:2020-11-27 22:28:23
文檔

js實(shí)現(xiàn)輪播圖的兩種方式(構(gòu)造函數(shù)、面向?qū)ο?

本文實(shí)例為大家分享了js實(shí)現(xiàn)輪播圖的具體代碼,供大家參考,具體內(nèi)容如下:1、構(gòu)造函數(shù)。<,0,0,index++ picImg[index].style.display='none';tabLi[index].className='';index++;index%=tabLi.length;picImg[index].style.display='block';tabLi[index].className='on';},2000) };<;/script>;<;/body>;<;/html>。2、面向?qū)ο螅?/div>
推薦度:
導(dǎo)讀本文實(shí)例為大家分享了js實(shí)現(xiàn)輪播圖的具體代碼,供大家參考,具體內(nèi)容如下:1、構(gòu)造函數(shù)。<,0,0,index++ picImg[index].style.display='none';tabLi[index].className='';index++;index%=tabLi.length;picImg[index].style.display='block';tabLi[index].className='on';},2000) };<;/script>;<;/body>;<;/html>。2、面向?qū)ο螅?/div>

本文實(shí)例為大家分享了js實(shí)現(xiàn)輪播圖的具體代碼,供大家參考,具體內(nèi)容如下

1、構(gòu)造函數(shù)

<!DOCTYPE html>
<html>
 <head>
 <meta charset="UTF-8">
 <title></title>
 <style type='text/css'>
 *{ margin:0; padding:0;}
 
 #wrap{
 width:500px;
 height:360px;
 margin:100px auto;
 position:relative;
 }

 #pic{
 width:500px;
 height:360px;
 position:relative;
 }

 #pic img{
 width: 100%;
 height: 100%;
 position:absolute;
 top:0;
 left:0;
 display:none;
 }

 #tab{
 width:105px;
 height:10px;
 position:absolute;
 bottom:10px;
 left:50%;
 margin-left:-50px;
 }

 #tab ul li{
 width:10px;
 height:10px;
 margin:0 5px;
 background:#bbb;
 border-radius:100%;
 cursor:pointer;
 list-style:none;
 float:left;
 }
 #tab ul li.on{ background:#f60;}

 #btn div{
 width:40px;
 height:40px;
 position:absolute;
 top:50%;
 margin-top:-20px;
 color:#fff;
 background:#999;
 background:rgba(0,0,0,.5);
 font-size:20px;
 font-weight:bold;
 font-family:'Microsoft yahei';
 line-height:40px;
 text-align:center;
 cursor:pointer;
 }
 #btn div#left{ left:0;}
 #btn div#right{ right:0;}

 </style>
 </head>
 <body>
 <div id="wrap">
 <div id="pic">
 <img src="img/1.jpg" alt="" />
 <img src="img/2.jpg" alt="" />
 <img src="img/3.jpg" alt="" />
 <img src="img/4.jpg" alt="" />
 </div>
 <div id="tab">
 <ul>
 <li></li>
 <li></li>
 <li></li>
 <li></li>
 </ul>
 </div>
 <div id="btn">
 <div id='left'><</div>
 <div id='right'>></div>
 </div>
 </div>
 <script>
 var oWrap=document.getElementById('wrap')
 var picImg=document.getElementById('pic').getElementsByTagName('img');
 var tabLi=document.getElementById('tab').getElementsByTagName('li');
 var btnDiv=document.getElementById('btn').getElementsByTagName('div');
 var index=0;
 var timer=null;//設(shè)置一個(gè)timer變量,讓他的值為空
 //初始化
 picImg[0].style.display='block';
 tabLi[0].className='on';
 
 for(var i=0;i<tabLi.length;i++){

 tabLi[i].index=i; 
 tabLi[i].onclick=function(){
 
 //不然要for循環(huán)清空
 /* for(var i=0;i<tabLi.length;i++){
 picImg[i].style.display='none'; 
 tabLi[i].className='';
 }*/
 picImg[index].style.display='none'; //每個(gè)li都有index自定義屬性
 tabLi[index].className='';
 index=this.index;
 picImg[index].style.display='block';
 tabLi[index].className='on';
 
 } 
 };
 for(var i=0;i<btnDiv.length;i++){

 btnDiv[i].index=i;
 btnDiv[i].onselectstart=function(){ //禁止選擇
 return false;
 }
 btnDiv[i].onclick=function(){
 
 picImg[index].style.display='none'; //每個(gè)li都有index自定義屬性
 tabLi[index].className='';
 //index=this.index;
 if(this.index){
 index++; //進(jìn)來(lái)就加1,index就相當(dāng)1%4 2%4 3%4 4%4
 //if(index>tabLi.length){index=0}
 //index=index%arrUrl.length; 自己取模自己等于0 alert(3%3) == 0 
 index%=tabLi.length;//相當(dāng)于當(dāng)大于tabLi.length就等于0
 }else{
 index--;
 if(index<0)index=tabLi.length-1; 
 } 
 picImg[index].style.display='block';
 tabLi[index].className='on';
 
 } 
 };
 auto();
 oWrap.onmouseover=function(){
 clearInterval(timer)
 }
 oWrap.onmouseleave=function(){
 auto();
 }
 function auto(){
 timer=setInterval(function(){ //一般都是向左輪播,index++
 picImg[index].style.display='none';
 tabLi[index].className='';
 index++;
 index%=tabLi.length;
 picImg[index].style.display='block';
 tabLi[index].className='on';
 },2000)
 };
 </script>
 </body>
</html>


2、面向?qū)ο?/p>

<!DOCTYPE html>
<html>
 <head>
 <meta charset="UTF-8">
 <title></title>
 <style type='text/css'>
 *{ margin:0; padding:0;}
 
 #wrap{
 width:500px;
 height:360px;
 margin:100px auto;
 position:relative;
 }

 #pic{
 width:500px;
 height:360px;
 position:relative;
 }

 #pic img{
 width: 100%;
 height: 100%;
 position:absolute;
 top:0;
 left:0;
 display:none;
 }

 #tab{
 width:105px;
 height:10px;
 position:absolute;
 bottom:10px;
 left:50%;
 margin-left:-50px;
 }

 #tab ul li{
 width:10px;
 height:10px;
 margin:0 5px;
 background:#bbb;
 border-radius:100%;
 cursor:pointer;
 list-style:none;
 float:left;
 }
 #tab ul li.on{ background:#f60;}

 #btn div{
 width:40px;
 height:40px;
 position:absolute;
 top:50%;
 margin-top:-20px;
 color:#fff;
 background:#999;
 background:rgba(0,0,0,.5);
 font-size:20px;
 font-weight:bold;
 font-family:'Microsoft yahei';
 line-height:40px;
 text-align:center;
 cursor:pointer;
 }
 #btn div#left{ left:0;}
 #btn div#right{ right:0;}

 </style>
 </head>
 <body>
 <div id="wrap">
 <div id="pic">
 <img src="img/1.jpg" alt="" />
 <img src="img/2.jpg" alt="" />
 <img src="img/3.jpg" alt="" />
 <img src="img/4.jpg" alt="" />
 </div>
 <div id="tab">
 <ul>
 <li></li>
 <li></li>
 <li></li>
 <li></li>
 </ul>
 </div>
 <div id="btn">
 <div id='left'><</div>
 <div id='right'>></div>
 </div>
 </div>
 <script>
 var oWrap=document.getElementById('wrap')
 var picImg=document.getElementById('pic').getElementsByTagName('img');
 var tabLi=document.getElementById('tab').getElementsByTagName('li');
 var btnDiv=document.getElementById('btn').getElementsByTagName('div');
 
 function Banner(oWrap,picImg,tabLi,btnDiv){
 this.wrap=oWrap
 this.list=picImg
 this.tab=tabLi
 this.btn=btnDiv
 this.index=0; //這些都必須是私有的,不然兩個(gè)banner會(huì)一樣
 this.timer=null;
 this.length=this.tab.length;
 
 // this.init();//下面創(chuàng)建好,要在這里執(zhí)行
 
 }
 
 //初始化分類
 Banner.prototype.init=function(){ //先把下面的分類
 var This=this; //var 一個(gè)This變量把this存起來(lái)
 this.list[0].style.display='block';
 this.tab[0].className='on';
 
 for(var i=0;i<this.length;i++){
 this.tab[i].index=i; 
 this.tab[i].onclick=function(){
 //this.list[index].style.display='none'; 這里的this指向tab的this 
 This.list[This.index].style.display='none'; 
 This.tab[This.index].className='';
 //index=this.index;
 This.index=this.index;
 This.list[This.index].style.display='block';
 //This.tab[This.index].className='on'; 
 this.className='on';
 } 
 };
 
 for(var i=0;i<this.btn.length;i++){
 this.btn[i].index=i;
 this.btn[i].onselectstart=function(){ 
 return false;
 }
 this.btn[i].onclick=function(){
 This.list[This.index].style.display='none'; 
 This.tab[This.index].className='';
 if(this.index){
 This.index++;
 This.index%=This.length; 
 }else{
 This.index--;
 if(index<0)This.index=This.length-1; 
 } 
 This.list[This.index].style.display='block';
 This.tab[This.index].className='on'; 
 }
 }
 this.auto();
 this.clear(); 
 };
 Banner.prototype.auto=function(){
 var This=this; 

 This.timer=setInterval(function(){ //一般都是向左輪播,index++
 This.list[This.index].style.display='none';
 This.tab[This.index].className='';
 This.index++;
 This.index%=This.length;
 This.list[This.index].style.display='block';
 This.tab[This.index].className='on';
 },2000)
 };
 
 Banner.prototype.clear=function(){
 var This=this; 
 this.wrap.onmouseover=function(){
 clearInterval(This.timer)
 }
 this.wrap.onmouseleave=function(){
 This.auto();
 } 
 };
 
 
 var banner1=new Banner(oWrap,picImg,tabLi,btnDiv);
 banner1.init();
 
 /*
 * init()
 * function init(){
 for(var i=0;i<tabLi.length;i++){
 tabLi[i].index=i; 
 tabLi[i].onclick=function(){
 picImg[index].style.display='none'; 
 tabLi[index].className='';
 index=this.index;
 picImg[index].style.display='block';
 tabLi[index].className='on'; 
 } 
 };
 
 
 }
 for(var i=0;i<btnDiv.length;i++){
 btnDiv[i].index=i;
 btnDiv[i].onselectstart=function(){ 
 return false;
 }
 btnDiv[i].onclick=function(){
 picImg[index].style.display='none'; 
 tabLi[index].className='';
 if(this.index){
 index++;
 index%=tabLi.length;
 }else{
 index--;
 if(index<0)index=tabLi.length-1; 
 } 
 picImg[index].style.display='block';
 tabLi[index].className='on';
 } 
 };
 auto();
 oWrap.onmouseover=function(){
 clearInterval(timer)
 }
 oWrap.onmouseleave=function(){
 auto();
 }
 function auto(){
 timer=setInterval(function(){ //一般都是向左輪播,index++
 picImg[index].style.display='none';
 tabLi[index].className='';
 index++;
 index%=tabLi.length;
 picImg[index].style.display='block';
 tabLi[index].className='on';
 },2000)
 };
 
 */
 </script>
 </body>
</html>


聲明:本網(wǎng)頁(yè)內(nèi)容旨在傳播知識(shí),若有侵權(quán)等問題請(qǐng)及時(shí)與本網(wǎng)聯(lián)系,我們將在第一時(shí)間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com

文檔

js實(shí)現(xiàn)輪播圖的兩種方式(構(gòu)造函數(shù)、面向?qū)ο?

本文實(shí)例為大家分享了js實(shí)現(xiàn)輪播圖的具體代碼,供大家參考,具體內(nèi)容如下:1、構(gòu)造函數(shù)。<,0,0,index++ picImg[index].style.display='none';tabLi[index].className='';index++;index%=tabLi.length;picImg[index].style.display='block';tabLi[index].className='on';},2000) };<;/script>;<;/body>;<;/html>。2、面向?qū)ο螅?/div>
推薦度:
  • 熱門焦點(diǎn)

最新推薦

猜你喜歡

熱門推薦

Top
主站蜘蛛池模板: 恭城| 漳浦县| 疏附县| 山东省| 武冈市| 启东市| 武城县| 宾阳县| 澄江县| 玉树县| 通化县| 寻乌县| 龙口市| 齐河县| 临猗县| 霍州市| 永和县| 都江堰市| 新竹县| 教育| 乌恰县| 南澳县| 伊川县| 久治县| 淅川县| 玉山县| 扎兰屯市| 河东区| 宽城| 乌鲁木齐县| 吴川市| 安国市| 宜川县| 新野县| 区。| 上林县| 阜新| 阜阳市| 米脂县| 竹山县| 安宁市|