";
for(var i=0; i < lenc1027241; i++) {
btnc1027241 += "";
}
btnc1027241 += " ";
$("#focusc1027241").append(btnc1027241);
$("#focusc1027241 .btnBgc1027241").css("opacity",0.5);
//为小按钮添加鼠标滑入事件,以显示相应的内容
$("#focusc1027241 .btnc1027241 span").css("opacity",0.4).mouseenter(function() {
indexc1027241 = $("#focusc1027241 .btnc1027241 span").index(this);
showPics(indexc1027241);
}).eq(0).trigger("mouseenter");
//上一页、下一页按钮透明度处理
$("#focusc1027241 .preNextc1027241").css("opacity",0.2).hover(function() {
$(this).stop(true,false).animate({"opacity":"0.5"},300);
},function() {
$(this).stop(true,false).animate({"opacity":"0.2"},300);
});
//上一页按钮
$("#focusc1027241 .prec1027241").click(function() {
indexc1027241 -= 1;
if(indexc1027241 == -1) {indexc1027241 = lenc1027241 - 1;}
showPics(indexc1027241);
});
//下一页按钮
$("#focusc1027241 .nextc1027241").click(function() {
indexc1027241 += 1;
if(indexc1027241 == lenc1027241) {indexc1027241 = 0;}
showPics(indexc1027241);
});
//本例为左右滚动,即所有li元素都是在同一排向左浮动,所以这里需要计算出外围ul元素的宽度
$("#focusc1027241 ul").css("width",sWidthc1027241 * (lenc1027241));
//鼠标滑上焦点图时停止自动播放,滑出时开始自动播放
$("#focusc1027241").hover(function() {
clearInterval(picTimerc1027241);
},function() {
picTimerc1027241 = setInterval(function() {
showPics(indexc1027241);
indexc1027241++;
if(indexc1027241 == lenc1027241) {indexc1027241 = 0;}
},4000); //此4000代表自动播放的间隔,单位:毫秒
}).trigger("mouseleave");
//显示图片函数,根据接收的index值显示相应的内容
function showPics(indexc1027241) { //普通切换
var nowLeftc1027241 = -indexc1027241*sWidthc1027241; //根据index值计算ul元素的left值
$("#focusc1027241 ul").stop(true,false).animate({"left":nowLeftc1027241},300); //通过animate()调整ul元素滚动到计算出的position
$("#focusc1027241 .btnc1027241 span").stop(true,false).animate({"opacity":"0.4"},300).eq(indexc1027241).stop(true,false).animate({"opacity":"1"},300); //为当前的按钮切换到选中的效果
}
});
|
|
|