一区二区久久-一区二区三区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久久国产视频 | 久热精品视频在线观看99小说 | 久久婷婷五色综合夜啪 | 国产自精品在线 | 一二三四在线视频社区1 | www色.com | 尤物yw午夜国产精品视频 | baoyu777永久免费视频 | 日本高清色视频在线观看免费 | 成人a毛片手机免费播放 | 伊人色综合97 | 成人激情在线 | 亚洲综合一区二区三区四区 | 六月综合网 | 黄色影院7755 | www日本高清视频 | 久久久久久一级毛片免费无遮挡 | 四虎激情影院 | 色com| 国产日韩欧美成人 | 亚洲国产第一 | 国产专区视频 | 天天操天天干天天爽 | 欧美成人免费sss | 国产福利小视频高清在线观看 | 午夜小视频在线播放 | bt日韩| 爽天天天天天天天 | 国产91精品露脸国语对白 | 亚洲乱人伦精品图片 | 久久精品国产99精品国产2021 | 国产全黄三级国产全黄三级书 | 伊人222成人综合网 伊人22综合 | 人人干97 | 国产对白在线播放九色 | 夜色视频一区二区三区 | 有码中文字幕在线观看 | 久久精品国产999久久久 | 最新亚洲一区二区三区四区 | 91免费影视 | 五色婷婷 |