图片随机轮播
$(document).ready(function(){
var ShowCount = 6;//显示数量
var i;
var str="";
var str2="";
function mixArray(source)
{
//var source=[1,2,3,4,5];
var goal=[];
for(var i=0;i<source.length;i++)
{
var pos=Math.floor(Math.random()*(source.length-i));
goal[i]=source[pos];
source[pos]=source[source.length-1-i];
}
return goal;
}
var Ro = new Array();
for (var x=0;x<6 ;x++ )
{
Ro[x]=x;
}
Ro=mixArray(Ro);
var z=0;
var Ros = new Array();
$(".highlight_tip ul li").each(function() {
$(this).attr("class",($(this).attr("class").replace("tab"+(z+1),"tab"+(Ro[z]+1))));
Ros[Ro[z]]=($(this));
z++;
});
$(".highlight_tip ul").empty();
for (var j=0;j<6 ; j++){
$(".highlight_tip ul").append(Ros[j]);
}
var Ross = new Array();
var s=0;
$(".v_content_list ul li").each(function() {
Ross[Ro[s]]=($(this));
s++;
});
$(".v_content_list ul").empty();
for (var m=0;m<6 ; m++){
$(".v_content_list ul").append(Ross[m]);
}
var picWidth = $(".v_content_list").width(); //获取显示焦点图的宽度
var len = $(".v_content_list ul li").length; //获取焦点图个数
var img_container = $(".v_content_list ul"); //定义变量
var button_container = $(".highlight_tip li"); //定义变量
var index = 0; //初始化index=0
$("#checkimg").hide();
$("#checkimg").slideDown(3000);
setTimeout(checkimgc,3000);
function checkimgc(){
$("#checkimg").slideUp(5000);
}
//$("#checkimg").click(function(data){
// window.location.href = "ActivityMedical.html";
//});
//设置tab按钮的背景透明度为0.5
//$(".highlight_bg").css("opacity","0.5")
//为tab按钮添加鼠标滑入事件,以显示相应的内容
button_container.mouseenter(function() {
index = button_container.index(this);
showPics(index);
}).eq(0).trigger("mouseenter");
//计算出外围ul元素的宽度
img_container.css("width",picWidth * (len));
//鼠标滑上焦点图时停止自动播放,滑出时开始自动播放
$(".v_content_list").hover(function() {
clearInterval(picTimer);
},function() {
picTimer = setInterval(function() {
showPics(index);
index++;
if(index == len) {index = 0;}
},4000); //4000代表自动播放的间隔,单位:毫秒,1秒=1000毫秒
}).trigger("mouseleave");
//显示图片函数,根据接收的index值显示相应的内容
function showPics(index) { //默认效果
var nowLeft = -index*picWidth; //根据index值计算ul元素的left值
//alert(nowLeft);
img_container.stop(true,false).animate({"left":nowLeft},300); //通过animate()调整ul元素滚动到计算出的position
button_container.eq(index).addClass("current").siblings().removeClass("current"); //为当前的tab按钮添加class="current"
//button_container.eq(index).stop(true).animate({"opacity":"1","top":-5+"px"},300).siblings().stop(true).animate({"opacity":"0.6","top":10+"px"},300); //为当前的tab按钮添加选中的效果
}
})
<div class="w733 fl" style="height:380px;">
<div class="highlight_tip">
<ul class="tab clear"><li class="tab1 navigation"><a href="goodsinfo/KX0049001212.html" target="_blank"><img src="imgs/index/upload_74ace7ae_e0b9_43e5_9fcd_4c7a2a4396ca_00000082.tmp.jpg" alt="点击进去查看详情" onclick="checksvp(this.id)" id="62"></a></li></ul>
</div>
<div class="v_content_list">
<ul class="clear" style="left: -1450px; width: 4350px;"><li><a href="/goodsinfo/KX0049001212.html" target="_blank"><img src="imgs/index/upload_74ace7ae_e0b9_43e5_9fcd_4c7a2a4396ca_00000082.tmp.jpg" alt="药品批发" onclick="checksvp(this.id)" id="62"></a></li></ul>
</div>
</div>

浙公网安备 33010602011771号