js圖片輪播圖

來源:互聯網
上載者:User

標籤:io   ar   sp   on   cti   bs   ad   size   as   

/*焦點圖*/
        var Box=‘.carousel‘;//盒子
        var Menu=$(Box+‘ .l_cursor li‘);//圓點菜單
        var Con=$(Box+‘ .carouselChange li‘);//大圖
        var Text=$(Box+‘ .text li‘);//圖注文字
        var Prev=$(Box+‘ .Prev‘);//上一頁
        var Next=$(Box+‘ .next‘);//下一頁
        var Counts=$(Con).size();//擷取li總數
        var nowIndex=0;
        var timer;
        /* 點擊切換 */
        $(Menu).click(function(){
            var i=$(Menu).index(this)
            gotoPage(i);
        });
        /* 開啟相應的標籤 */
        function gotoPage(i){
            $(Menu).removeClass("current").eq(i).addClass("current");
            $(Con).fadeOut(200).eq(i).fadeIn(200);
            $(Text).hide().eq(i).fadeIn(200);
            nowIndex=i;
        };
        /* 下一頁 */
        $(Next).click(function(){
            gotoR();
        });
        function gotoR(){
            nowIndex++;
            if(nowIndex > Counts-1){
                nowIndex=0;
            }
            gotoPage(nowIndex);
        };
        /* 上一頁 */
        $(Prev).click(function(){
            nowIndex--;
            if(nowIndex < 0){
                nowIndex=Counts-1
            }
            gotoPage(nowIndex);
        });
        /* 自動輪播 */
        function setAuto(){
            if(Counts>1){
                timer=setInterval(gotoR,3000);
            };
        };
        setAuto();
        /* 滑鼠經過暫停,離開繼續輪播 */
        $(Box).hover(function(){
                    $(Prev).show();
                    $(Next).show();
                    if(timer){
                        clearInterval(timer);
                    }
                },
                function(){
                    $(Prev).hide();
                    $(Next).hide();
                    setAuto();
                });
        /*焦點圖*/

js圖片輪播圖

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.