jQuery点击缩略图切换大图,缩略图若是很多的话,支持分页,左右按钮滚动,点击大图左右按钮,到一定数量,缩略图会跟着滚动。
0、请不要问“在不在”之类的问题,有问题直接问!1、学生或暂时没有工作的童鞋,整站资源免费下载!2、¥9.9充值终身VIP会员,加我微信,826096331 拉你进VIP群学习!3、程序员加油,技术改变世界。在线 充值
//mouseover效果
function liMouseOn() {
$(".scrolltab .ulBigPic li").attr("class", "");
for (var i = 0; i < $(".scrolltab .ulBigPic li").length; i++) {
(function(j) {
$(".scrolltab .ulBigPic li:eq(" + j + ")").mouseover(function() {
if ($(".scrolltab").attr("class") == "dSmallList" || $(".scrolltab").attr("class") == "dMiddleList") {
if ($(this).attr("class") != "liSelected") {
$(this).attr("class", "liSelected");
}
}
});
$(".scrolltab .ulBigPic li:eq(" + j + ")").mouseout(function() {
if ($(".scrolltab").attr("class") == "dSmallList" || $(".scrolltab").attr("class") == "dMiddleList") {
if ($(this).attr("class") == "liSelected") {
$(this).attr("class", "");
}
}
});
})(i);
}
}
//定义当前、之前、之后要显示图片的排位
var curPic = 0, nextPic = -1, prePic = -1;
preShowPic = -1;
var allPic = $(".scrolltab .ulBigPic li").length;
//初始化当前、之前、之后要显示图片的排位
function numInit(num) {
if (num == "init") {
if (allPic > 1) {
nextPic = curPic + 1;
prePic = allPic - 1;
} else if (allPic == 1) {
nextPic = 0;
prePic = 0;
}
$(".scrolltab .ulBigPic li:eq(" + curPic + ")").attr("class", "liSelected");
} else if (num == "plus") {
preShowPic = curPic;
prePic = curPic;
curPic = nextPic;
if (curPic < (allPic - 1)) {
nextPic = curPic + 1;
} else if (curPic == (allPic - 1)) {
nextPic = 0;
}
$(".scrolltab .ulBigPic li:eq(" + curPic + ")").attr("class", "liSelected");
if (preShowPic != curPic) {
$(".scrolltab .ulBigPic li:eq(" + preShowPic + ")").attr("class", "");
}
} else if (num == "minus") {
preShowPic = curPic;
nextPic = curPic;
curPic = prePic;
if (curPic > 0) {
prePic = curPic - 1;
} else if (curPic == 0 && allPic > 1) {
prePic = allPic - 1;
}
$(".scrolltab .ulBigPic li:eq(" + curPic + ")").attr("class", "liSelected");
if (preShowPic != curPic) {
$(".scrolltab .ulBigPic li:eq(" + preShowPic + ")").attr("class", "");
}
} else {
preShowPic = curPic;
curPic = num;
if (curPic == (allPic - 1)) {
nextPic = 0;
if (allPic > 1) {
prePic = curPic - 1;
} else if (allPic == 1) {
prePic = 0;
}
} else if (curPic == 0) {
prePic = allPic - 1;
if (allPic > 1) {
nextPic = 1;
} else if (allPic == 1) {
nextPic = 0;
}
} else {
nextPic = curPic + 1;
prePic = curPic - 1;
}
$(".scrolltab .ulBigPic li:eq(" + curPic + ")").attr("class", "liSelected");
if (preShowPic != curPic) {
$(".scrolltab .ulBigPic li:eq(" + preShowPic + ")").attr("class", "");
}
}
//alert("curPic="+curPic+"/nextPic="+nextPic+"/prePic="+prePic+"/preShowPic="+preShowPic);
}
//大图左右按钮初始化
function btnAInit() {
if (allPic < 2) {
$("#sLeftBtnA").attr("class", "sLeftBtnABan");
$("#sRightBtnA").attr("class", "sRightBtnABan");
} else {
if (curPic == 0) {
$("#sLeftBtnA").attr("class", "sLeftBtnABan");
$("#sRightBtnA").attr("class", "sRightBtnA");
} else if (curPic == (allPic - 1)) {
$("#sLeftBtnA").attr("class", "sLeftBtnA");
$("#sRightBtnA").attr("class", "sRightBtnABan");
} else {
$("#sLeftBtnA").attr("class", "sLeftBtnA");
$("#sRightBtnA").attr("class", "sRightBtnA");
}
}
}
//小图左右按钮初始化
function btnBInitA() {
if (allPic > 6) {
$("#sRightBtnB").attr("class", "sRightBtnB");
}
}
友情提示:垃圾评论一律封号 加我微信:826096331拉你进VIP群学习群