$(document).ready(function () { $(".items").DuZhan_hotprotz({ showclass: ".items", show_leg: "4"}); $(".items ul li").removeClass("cur").eq(0).addClass("cur"); //图片放大镜效果 $(function(){ //$(".jqzoom").jqueryzoom({xzoom:380,yzoom:410}); }); //产品图片切换 $(".items ul li").mousemove(function(){ var index=$(".items ul li").index(this); $(".items ul li").removeClass("cur").eq(index).addClass("cur"); $(".jqzoom img").attr("src",$(".items ul li img").eq(index).attr("src")); $(".jqzoom img").attr("jqimg",$(".items ul li img").eq(index).attr("src")); }) }); (function ($) { $.fn.DuZhan_hotprotz = function (options) { var defaults = { showclass: "", showspanindex: "", showtime: "10000", show_leg: "4" }; var showindex = 0; var options = $.extend(defaults, options); var showlist = $(options.showclass + " li"); var showfirst = showlist.eq(0); if ($(document).width() <= 1270) { options.show_leg = 2; }else if($(document).width() <= 1460){ options.show_leg = 3; } var len = $(options.showclass + " li").length - options.show_leg+1; var index = 0; var showcur = "cur"; var shownowclass = options.showclass; var picTimer; var sWidth = showfirst.outerWidth(true) * options.show_leg; var movewidth = $(options.showclass + " li ").outerWidth(true); //浏览器变化时 $(window).resize(function () { clearInterval(picTimer); if ($(document).width() <= 1270) { options.show_leg = 2; }else if($(document).width() <= 1460){ options.show_leg = 3; } movewidth = $(options.showclass + " li ").outerWidth(true); len = $(options.showclass + " li").length - options.show_leg+1; }); $(".prev").click(function(){ if (index > 0) { index--; showMove(); } }); $(".next").click(function(){ if (index < len - 1) { index++; showMove(); } }); function AutoMove() { index++; if (index >= len) { index = 0; } showMove(index); } function showMove() { if (index < len) { var nowLeft = -index * movewidth; $(options.showclass + ".items ul").css("transform","translateX("+nowLeft+"px)"); $(".items ul li").removeClass("cur").eq(index).addClass("cur"); $(".jqzoom img").attr("src",$(".items ul li img").eq(index).attr("src")); $(".jqzoom img").attr("jqimg",$(".items ul li img").eq(index).attr("src")); $(window).trigger('scroll'); } else { index = 0; } } } })(jQuery)