• <noscript id="ecgc0"><kbd id="ecgc0"></kbd></noscript>
    <menu id="ecgc0"></menu>
  • <tt id="ecgc0"></tt>

    百度小程序如何實現jQuery輪播效果

    相信列位初學寫小法式的新手們,都需要一些案例來仿照進修。今天給大師供給一個輪播結果的實現方式,供大師參考。

    東西/原料

    • jQuery

    方式/步調

    1. 1

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

        <script type="text/javascript">

            var timer;

            $(function() {

              //設置圖片標的目的左移

              imgshow();

              //點擊暫停按鈕事務

              $(".pause").click(function () {

                clearInterval(timer);

              });

              //點擊播放按鈕事務

              $(".play").click(function () {

                imgshow();

              });

    2. 2

       //點擊左按鈕

              $(".prev").click(function () {

                imganimation("left");

              });

              //點擊右按鈕

              $(".next").click(function () {

                imganimation("right");

              });

              function imganimation(res) {

                //圖片標的目的左走的輪播

                if(res=="right"){

                  //animate()動畫第一個li標的目的左移動20%

                  $(".lilist:first").animate({

                    "marginLeft": "-20%"

                  }, 700, "linear", function () {

                    //這個li回到本來的位置

                    $(this).css("marginLeft", "0px");

                    //將它追加到ul的最后的位置

                    $(this).appendTo($(".ullist"));

                  });

                  //設置小框的圖片輪播,道理與年夜框圖片輪播一致

                  $(".s_lilist:first").animate({

                    "marginLeft": "-20%"

                  }, 650, "linear", function () {

                    $(this).css("marginLeft", "0px");

                    $(this).appendTo($(".s_ullist"));

                  });

    3. 3

       //圖片標的目的右走,與標的目的左的道理不異

                  $(".lilist:first").animate({

                    "marginLeft": "20%"

                  }, 700, "linear", function () {

                    $(this).css("marginLeft", "0px");

                    $(".lilist:last").prependTo($(".ullist"));

                  });

                  $(".s_lilist:first").animate({

                    "marginLeft": "20%"

                  }, 650, "linear", function () {

                    $(this).css("marginLeft", "0px");

                    $(".s_lilist:last").prependTo($(".s_ullist"));

                  });

                };

              };

              //默認圖片主動標的目的左走

              function imgshow() {

                timer = setInterval(function (){

                      imganimation("right");

                    } , 2000);

              };

            });

          </script>

    4. 4

      最后,附上css樣式與html樣式。

    注重事項

    • 代碼僅供參考,接待大師一路交流進修。
    • 發表于 2018-07-19 00:00
    • 閱讀 ( 819 )
    • 分類:其他類型

    你可能感興趣的文章

    相關問題

    0 條評論

    請先 登錄 后評論
    admin
    admin

    0 篇文章

    作家榜 ?

    1. xiaonan123 189 文章
    2. 湯依妹兒 97 文章
    3. luogf229 46 文章
    4. jy02406749 45 文章
    5. 小凡 34 文章
    6. Daisy萌 32 文章
    7. 我的QQ3117863681 24 文章
    8. 華志健 23 文章

    聯系我們:uytrv@hotmail.com 問答工具
  • <noscript id="ecgc0"><kbd id="ecgc0"></kbd></noscript>
    <menu id="ecgc0"></menu>
  • <tt id="ecgc0"></tt>
    久久久久精品国产麻豆