jQuery實(shí)現(xiàn)一個(gè)簡(jiǎn)單的輪播圖
html代碼:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <title>輪播圖練習(xí)</title> <link rel="stylesheet" href="css/css.css" rel="external nofollow" type="text/css"/> </head> <body> <ul class="back"> <!-- 背景圖片 --> <li class="l1"></li> <li class="l2"></li> <li class="l3"></li> <li class="l4"></li> <li class="l5"></li> </ul> <ul class="point"> <!-- 控制按鈕 --> <li class="active"></li> <li></li> <li></li> <li></li> <li></li> </ul> <div class="btn"> <!-- 左右控制按鈕 --> <span class="prev"></span> <span class="next"></span> </div> </body> <script src="js/jquery-1.7.2.js"></script> <script src="js/jq.js"></script> </html>
css代碼:
*{margin:0; padding: 0;} ul li{list-style: none;} .back{height: 400px; overflow: hidden; margin-top:100px;} .back li{width: 100%; height: 400px; margin:0 auto;} .back li.l1{background: red;} .back li.l2{background: yellow;} .back li.l3{background: blue;} .back li.l4{background: black;} .back li.l5{background: green;} .point{text-align: center; margin-top: -30px;} .point li{ width: 20px; height: 20px; border:2px solid #fff; border-radius: 10px; box-sizing:border-box; display: inline-block;} .point li.active{background: #fff;} .btn{ position: relative;} .btn span{ display: inline-block; vertical-align: top; width: 100px; height: 100px; background: rgba(0,0,0,.5); position: absolute; top:-235px; cursor: pointer;} .btn .prev{left: 0} .btn .next{ right: 0;}
js代碼:
$(function(){ function banner(a,b,c,d,e){ // a是背景圖,b是active,c是背景對(duì)應(yīng)按鈕,d是上一頁(yè),e是下一頁(yè) index=0; len=$(a).length-1; function teb(index){ $(c).eq(index).addClass(b).siblings('').removeClass(b); $(a).eq(index).fadeIn(300).addClass('curr').siblings('').fadeOut(300).removeClass('curr'); }; $(c).click(function(){ index=$(this).index(); teb(index); }); $(d).click(function(){ index--; if(index<0){ index=len; }; teb(index); }); $(e).click(function(){ index++; if(index>len){ index=0; }; teb(index); }); function timeRun(){ time=setInterval(function(){ index++; if(index>len){ index=0; }; teb(index); },3000); }; timeRun(); }; banner('.back>li','active','.point>li','.prev','.next'); });
以上就是本文的全部?jī)?nèi)容,希望本文的內(nèi)容對(duì)大家的學(xué)習(xí)或者工作能帶來(lái)一定的幫助,同時(shí)也希望多多支持腳本之家!
- jquery實(shí)現(xiàn)左右無(wú)縫輪播圖
- jQuery插件slides實(shí)現(xiàn)無(wú)縫輪播圖特效
- jquery實(shí)現(xiàn)左右滑動(dòng)式輪播圖
- 基于jQuery實(shí)現(xiàn)淡入淡出效果輪播圖
- jQuery無(wú)縫輪播圖代碼
- jquery實(shí)現(xiàn)左右輪播圖效果
- 原生Javascript和jQuery做輪播圖簡(jiǎn)單例子
- jQuery實(shí)現(xiàn)輪播圖源碼
- jQuery實(shí)現(xiàn)簡(jiǎn)潔的輪播圖效果實(shí)例
- jquery實(shí)現(xiàn)簡(jiǎn)單自動(dòng)輪播圖效果
相關(guān)文章
jQuery position() 函數(shù)詳解以及jQuery中position函數(shù)的應(yīng)用
position()函數(shù)用于返回當(dāng)前匹配元素相對(duì)于其被定位的祖輩元素的偏移,也就是相對(duì)于被定位的祖輩元素的坐標(biāo)。該函數(shù)只對(duì)可見(jiàn)元素有效,通過(guò)本文給大家介紹jQuery position() 函數(shù)詳解以及jQuery中position函數(shù)的應(yīng)用,感興趣的朋友一起學(xué)習(xí)吧2015-12-12jQuery插件jcrop+Fileapi完美實(shí)現(xiàn)圖片上傳+裁剪+預(yù)覽的代碼分享
這篇文章主要介紹了jQuery插件jcrop+Fileapi完美實(shí)現(xiàn)圖片上傳+裁剪+預(yù)覽的代碼,非常的簡(jiǎn)單實(shí)用,效果也很棒,有需要的小伙伴可以參考下。2015-04-04BootStrap 標(biāo)題設(shè)置跨行無(wú)效的解決方法
這篇文章主要介紹了BootStrap 標(biāo)題設(shè)置跨行無(wú)效的解決方法,需要的朋友可以參考下2017-10-10jQuery 動(dòng)畫(huà)與停止動(dòng)畫(huà)效果實(shí)例詳解
這篇文章主要介紹了jQuery 動(dòng)畫(huà)與停止動(dòng)畫(huà)效果,結(jié)合實(shí)例形式詳細(xì)分析了jQuery 動(dòng)畫(huà)與停止動(dòng)畫(huà)效果相關(guān)函數(shù)功能、用法及使用注意事項(xiàng),需要的朋友可以參考下2020-05-05單擊按鈕發(fā)送驗(yàn)證碼,出現(xiàn)倒計(jì)時(shí)的簡(jiǎn)單實(shí)例
下面小編就為大家?guī)?lái)一篇單擊按鈕發(fā)送驗(yàn)證碼,出現(xiàn)倒計(jì)時(shí)的簡(jiǎn)單實(shí)例。小編覺(jué)得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2017-03-03jquery(javascript)自動(dòng)序列編號(hào)和屬性編號(hào)實(shí)現(xiàn)代碼
jquery(javascript)自動(dòng)序列編號(hào)和屬性編號(hào)實(shí)現(xiàn)代碼,需要的朋友可以參考下2012-07-07jQuery使用jsonp實(shí)現(xiàn)百度搜索的示例代碼
這篇文章主要介紹了jQuery使用jsonp實(shí)現(xiàn)百度搜索,文中示例代碼非常詳細(xì),幫助大家更好的理解和學(xué)習(xí),感興趣的朋友可以了解下2020-07-07Jquery CheckBox全選方法代碼附j(luò)s checkbox全選反選代碼
喜歡上了Jquery的簡(jiǎn)便、明了···與用JavaScript寫(xiě)的比起來(lái)真的有點(diǎn)差距!2010-06-06