pic player
there is a pic-player
<script> <br> var p = $('#picplayer'); <br> 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}]; <br> initPicPlayer(pics1,p.css('width').split('px')[0],p.css('height').split('px')[0]); <br> // <br> // <br> function initPicPlayer(pics,w,h) <br> { <br> //选中的图片 <br> var selectedItem; <br> //选中的按钮 <br> var selectedBtn; <br> //自动播放的id <br> var playID; <br> //选中图片的索引 <br> var selectedIndex; <br> //容器 <br> var p = $('#picplayer'); <br> p.text(''); <br> p.append('<div id="piccontent"></div>'); <br> var c = $('#piccontent'); <br> for(var i=0;i<pics.length;i++) <BR> { <BR> //添加图片到容器中 <BR> c.append('<a href="'+pics[i].link+'" target="_blank"><img id="picitem'+i+'" style="display: none;z-index:'+i+'" src="'+pics[i].url+'" /></a>'); <br> } <br> //按钮容器,绝对定位在右下角 <br> p.append('<div id="picbtnHolder" style="position:absolute;top:'+(h-25)+'px;width:'+w+'px;height:20px;z-index:10000;"></div>'); <br> // <br> var btnHolder = $('#picbtnHolder'); <br> btnHolder.append('<div id="picbtns" style="float:right; padding-right:1px;"></div>'); <br> var btns = $('#picbtns'); <br> // <br> for(var i=0;i<pics.length> { <br> //增加图片对应的按钮 <br> btns.append('<span id= "picbtn' i '" style="cursor:pointer; border:solid 1px #ccc;background-color:#eee; display:inline-block;"> ' (i 1) ' </span> '); <br> $('#picbtn' i).data('index',i); <br> $('#picbtn' i).click( <br> function(event) <br> { <br> if(selectedItem.attr('src') == $('#picitem' $(this) .data('index')).attr('src')) <br> { <br> <br> <br> } <br> setSelectedItem($(this).data('index')); } <br> ); <br> }<br> btns.append(' '); <br> /// <br> setSelectedItem(0); <br>// <br> clearInterval(プレイID); <br> //alert(index); <br> if(selectedItem)selectedItem.fadeOut('fast'); <br> selectedItem = $('#picitem'index); <br> selectedItem.fadeIn('slow'); <br> // <br> if(selectedBtn) <br> <br> { Btn.css('backgroundColor','#eee'); <br> selectedBtn.css('color','#000'); <br> } <br> selectedBtn = $('#picbtn'index); <br> selectedBtn.css('backgroundColor','#000'); <br> selectedBtn.css('color','#fff'); <br> //自動播放 <br> playID = setInterval() <br> <br> { varindex = selectedIndex 1; <br> if(index > pics.length-1)index=0; > setSelectedItem(index)<br> },pics[index].time); <br> <br> } <br><br> <br><br> </script>