最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

jQuery實(shí)現(xiàn)一個(gè)簡單的輪播圖

 更新時(shí)間:2017年02月19日 14:46:13   作者:nameless-212  
本文主要介紹了jQuery實(shí)現(xiàn)一個(gè)簡單輪播圖的方法,具有很好的參考價(jià)值,下面跟著小編一起來看下吧

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是背景對應(yīng)按鈕,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');
});

以上就是本文的全部內(nèi)容,希望本文的內(nèi)容對大家的學(xué)習(xí)或者工作能帶來一定的幫助,同時(shí)也希望多多支持腳本之家!

相關(guān)文章

最新評論

临潭县| 淳安县| 富宁县| 赞皇县| 罗平县| 嘉兴市| 石城县| 堆龙德庆县| 班戈县| 晋江市| 凤台县| 平果县| 交口县| 阳原县| 平山县| 土默特右旗| 科技| 乌兰察布市| 静安区| 盘山县| 昌平区| 久治县| 疏勒县| 密山市| 开阳县| 马鞍山市| 夏津县| 化州市| 郯城县| 定安县| 渝中区| 三门县| 浙江省| 新津县| 大连市| 六盘水市| 将乐县| 平塘县| 阳泉市| 浦北县| 石阡县|