一区二区久久-一区二区三区www-一区二区三区久久-一区二区三区久久精品-麻豆国产一区二区在线观看-麻豆国产视频

js 圖片輪播(5張圖片)

演示地址:http://img.jb51.NET/online/picPlayer/picplay.htm
復制代碼 代碼如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>pic player</title>
        <script type="text/Javascript" src="http://img.jb51.NET/jslib/jquery/jquery-1.2.6.js"></script>
        <script type="text/Javascript" src="http://img.jb51.NET/jslib/jquery/tween.js"></script>
    </head>
    <style type="text/css">
    img{border:0;}
    </style>
    <body>
        <div id="picplayer" style="position:relative;overflow:hidden;width:300px;height:300px;clear:none;border:solid 1px #ccc;">
            there is a pic-player
        </div>
        <script>
            var p = $('#picplayer');
            var pics1 = [{url:'http://img.jb51.NET/online/picPlayer/1.jpg',link:'http://www.jb51.NET/#',time:5000},{url:'http://img.jb51.NET/online/picPlayer/2.jpg',link:'http://www.jb51.NET/#',time:4000},{url:'http://img.jb51.NET/online/picPlayer/3.jpg',link:'http://www.jb51.NET',time:6000},{url:'http://img.jb51.NET/online/picPlayer/2.jpg',link:'http://www.jb51.NET',time:6000},{url:'http://img.jb51.NET/online/picPlayer/1.jpg',link:'http://www.jb51.NET',time:6000}];
            initPicPlayer(pics1,p.css('width').split('px')[0],p.css('height').split('px')[0]);
            //
            //
            function initPicPlayer(pics,w,h)
            {
                //選中的圖片
                var selectedItem;
                //選中的按鈕
                var selectedBtn;
                //自動播放的id
                var playID;
                //選中圖片的索引
                var selectedIndex;
                //容器
                var p = $('#picplayer');
                p.text('');
                p.append('<div id="piccontent"></div>');
                var c = $('#piccontent');
                for(var i=0;i<pics.length;i++)
                {
                    //添加圖片到容器中
                    c.append('<a href="'+pics[i].link+'" target="_blank"><img id="picitem'+i+'" style="display: none;z-index:'+i+'" src="'+pics[i].url+'" /></a>');
                }
                //按鈕容器,絕對定位在右下角
                p.append('<div id="picbtnHolder" style="position:absolute;top:'+(h-25)+'px;width:'+w+'px;height:20px;z-index:10000;"></div>');
                //
                var btnHolder = $('#picbtnHolder');
                btnHolder.append('<div id="picbtns" style="float:right; padding-right:1px;"></div>');
                var btns = $('#picbtns');
                //
                for(var i=0;i<pics.length;i++)
                {
                    //增加圖片對應的按鈕
                    btns.append('<span id="picbtn'+i+'" style="cursor:pointer; border:solid 1px #ccc;background-color:#eee; display:inline-block;"> '+(i+1)+' </span> ');
                    $('#picbtn'+i).data('index',i);
                    $('#picbtn'+i).click(
                        function(event)
                        {
                            if(selectedItem.attr('src') == $('#picitem'+$(this).data('index')).attr('src'))
                            {
                                return;
                            }
                            setSelectedItem($(this).data('index'));
                        }
                    );
                }
                btns.append(' ');
                ///
                setSelectedItem(0);
                //顯示指定的圖片index
                function setSelectedItem(index)
                {
                    selectedIndex = index;
                    clearInterval(playID);
                    //alert(index);
                    if(selectedItem)selectedItem.fadeOut('fast');
                    selectedItem = $('#picitem'+index);
                    selectedItem.fadeIn('slow');
                    //
                    if(selectedBtn)
                    {
                        selectedBtn.css('backgroundColor','#eee');
                        selectedBtn.css('color','#000');
                    }
                    selectedBtn = $('#picbtn'+index);
                    selectedBtn.css('backgroundColor','#000');
                    selectedBtn.css('color','#fff');
                    //自動播放
                    playID = setInterval(function()
                    {
                        var index = selectedIndex+1;
                        if(index > pics.length-1)index=0;
                        setSelectedItem(index);
                    },pics[index].time);
                }
            }

            

        </script>

        
    </body>
</html>

如果想增加圖片可以通過增加 var pics1 后面的內容。即可。

JavaScript技術js 圖片輪播(5張圖片),轉載需保留來源!

鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。

主站蜘蛛池模板: 久久伊人久久亚洲综合 | 久久夜色精品国产欧美 | 国产精品自拍亚洲 | 国产区在线观看 | 91精品国产自产在线观看 | 91九色国产 | 加勒比一区二区 | 伊人不卡久久大香线蕉综合影院 | 亚洲最大视频网 | 亚洲人成伊人成综合网久久久 | 久久综合久久鬼 | 欧美大陆| 国产精品久久久久久亚洲小说 | 韩国免费毛片在线看 | 人人九九精| 国产亚洲欧美另类久久久 | 精品美女在线 | 一区二区三区国产美女在线播放 | 日韩高清一区二区三区五区七区 | 久草色在线 | 日本一区二区在线播放 | 久久综合久久综合久久综合 | 国产精品国产三级国产专不∫ | 国产女乱淫真高清免费视频 | 国产精品女人在线观看 | 樱花aⅴ一区二区三区四区 影音先锋 色天使 | 久久亚洲精品国产亚洲老地址 | 国产成人精品午夜视频' | 国内精品免费一区二区三区 | 免费观看成人www精品视频在线 | 四虎影视国产在线观看精品 | 亚洲视频网站在线观看 | 91久久国产精品视频 | 国产麻豆免费观看91 | 亚洲福利视频网站 | 亚州欧美 | 国产真实乱子伦精品视 | 久久精选视频 | 国产精品亚洲自在线播放页码 | 久久久久久久久久免观看 | 亚洲国产视频网站 |