<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="/1999/xhtml">
<head>
<title>pic player</title>
<script type="text/javascript" src="img.jb51/jslib/jquery/jquery-1.2.6.js"></script>
<script type="text/javascript" src="img.jb51/jslib/jquery/tween.js"></script>
</head>
<style type="text/css">
img{border:0;}
</style>
<body>
<div id="picplayer" rtcscls-1-s_r_0 rtcscls-1-r_1">1px #ccc;">
there is a pic-player
</div>
<script>
var p = $('#picplayer');
var pics1 = [{url:'img.jb51/online/picPlayer/1.jpg',link:'sgroup.tk',time:5000},{url:'img.jb51/online/picPlayer/2.jpg',link:'sgroup.tk',time:4000},{url:'img.jb51/online/picPlayer/3.jpg',link:'sgroup.tk',time:6000},{url:'img.jb51/online/picPlayer/2.jpg',link:'sgroup.tk',time:6000},{url:'img.jb51/online/picPlayer/1.jpg',link:'sgroup.tk',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+'" src="'+pics[i].url+'" /></a>');
}
//按钮容器,绝对定位在右下角
p.append('<div id="picbtnHolder" ></div>');
//
var btnHolder = $('#picbtnHolder');
btnHolder.append('<div id="picbtns" ></div>');
var btns = $('#picbtns');
//
for(var i=0;i<pics.length;i++)
{
//增加图片对应的按钮
btns.append('<span id="picbtn'+i+'" > '+(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 js实现轮播图最简代码后面的内容

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。