国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JavaScript > 正文

jQuery實現一個簡單的輪播圖

2019-11-19 17:30:38
字體:
來源:轉載
供稿:網友

html代碼:

<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8" /><title>輪播圖練習</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是背景對應按鈕,d是上一頁,e是下一頁    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');});

以上就是本文的全部內容,希望本文的內容對大家的學習或者工作能帶來一定的幫助,同時也希望多多支持武林網!

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 蕉岭县| 张家界市| 昭苏县| 微山县| 密山市| 鹤庆县| 盘锦市| 平乡县| 元江| 张家界市| 龙泉市| 光山县| 都兰县| 海安县| 东莞市| 宁城县| 武邑县| 武城县| 百色市| 冕宁县| 景宁| 明星| 丹棱县| 合水县| 拜泉县| 鄂温| 德令哈市| 衡阳县| 遵化市| 电白县| 林西县| 清流县| 玛沁县| 仙居县| 济源市| 都江堰市| 德保县| 林西县| 灵武市| 剑河县| 岑巩县|