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

    1. jQuery實(shí)現(xiàn)簡單輪播圖效果

       更新時(shí)間:2020年12月27日 10:45:43   作者:阡禧  
      這篇文章主要為大家詳細(xì)介紹了jQuery實(shí)現(xiàn)簡單輪播圖效果,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

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

      介紹:這里是我使用了計(jì)時(shí)器的方式實(shí)現(xiàn)圖片每隔幾秒切換然后添加了兩個(gè)按鈕用于上一張和下一張的切換

      1、導(dǎo)入jQuery文件

      <script src="jquery-3.5.1.js"></script>

      2、設(shè)置圖片的樣式

      <style>
        *{
         margin: 0;
         padding: 0;
        }
        #box{
         width: 300px;
         height: 300px;
         border: 2px solid red;
        }
        #box img{
         position: absolute;
         display: none;
        }
        #box :first-child{
         display: block;
        }
        .page{
         list-style: none;
         display: flex;
         width: 300px;
         justify-content: space-around;
        }
        .page li{
         border: 1px solid red;
         border-radius: 50%;
         width: 20px;
         height: 20px;
         text-align: center;
      
        }
        .active{
         background: red;
        }
       </style>
       <script src="./jquery.js"></script>
      </head>
      <body>
       <div id="box">
        <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> 
       <ul class="page" id="page" >
        <li class="active">1</li>
        <li>2</li>
        <li>3</li>
        <li>4</li>
       </ul>
      <button id="next">下一張</button>
      <button id="prev">上一張</button>

      3 進(jìn)行圖片的輪播實(shí)現(xiàn)方式

      /*
       絕對定位 -- 摞起來
       通過下標(biāo) -- 顯示當(dāng)前 --其他兄弟 隱藏
      */
        <script>
         var index=0;
          // 移動(dòng)方法
         function move(){
          index++;
          if (index>=$("#box img").length) {
           index=0;
          }
          $("#box img").eq(index).show().siblings().hide();
          $("#page li").eq(index).addClass("active").siblings().removeClass("active");
         }
         //計(jì)時(shí)器的實(shí)現(xiàn)方法
         var t=setInterval(move,2000);
         //鼠標(biāo)移動(dòng)到圖片會停止離開繼續(xù)輪播
         $("#box").hover(function(){
          clearInterval(t)
         },function(){
          t=setInterval(move,2000)
         })
      
         $("#page li").click(function(){
          index= $(this).index() ;
          $("#box img").eq(index).show().siblings().hide();
          $("#page li").eq(index).addClass("active").siblings().removeClass("active");
         })
         //下一張的點(diǎn)擊
         $("#next").click(function(){
          move();
         })
         //上一張的點(diǎn)擊
         $("#prev").click(function(){
          index--;
          // 判斷如果下標(biāo)超過固有圖片的數(shù)量時(shí),從頭開始輪播
          if (index<0) {
           index=$("#box img").length-1;
          }
          $("#box img").eq(index).show().siblings().hide();
          $("#page li").eq(index).addClass("active").siblings().removeClass("active");
         })
      
      </script>

      以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

      相關(guān)文章

      最新評論

      阳谷县| 德庆县| 高陵县| 陈巴尔虎旗| 富民县| 哈巴河县| 咸阳市| 沧州市| 滦南县| 十堰市| 广宗县| 北海市| 上饶市| 巴青县| 凌云县| 杭锦旗| 桐城市| 镇赉县| 龙川县| 安塞县| 会同县| 兰坪| 蓬莱市| 沈阳市| 桃源县| 建始县| 凤台县| 洪泽县| 岫岩| 留坝县| 元阳县| 牟定县| 芜湖市| 穆棱市| 蓬安县| 泸定县| 定边县| 西贡区| 威海市| 宁波市| 马边|