//=====================全局函数======================== //tab控制函数 function tabs(tabid, tabnum){ //设置点击后的切换样式 $(tabid + " .tab li").removeclass("curr"); $(tabid + " .tab li").eq(tabnum).addclass("curr"); //根据参数决定显示内容 $(tabid + " .tabcon").hide(); $(tabid + " .tabcon").eq(tabnum).show(); } //=====================全局函数======================== //==================图片详细页函数===================== //鼠标经过预览图片函数 function preview(img){ $("#preview .jqzoom img").attr("src",$(img).attr("src")); $("#preview .jqzoom img").attr("jqimg",$(img).attr("bimg")); $(".img-hover").removeclass("img-hover"); $(img).addclass("img-hover"); } //图片放大镜效果 $(function(){ $(".jqzoom").jqueryzoom({xzoom:380,yzoom:410}); }); //图片预览小图移动效果,页面加载时触发 $(function(){ var templength = 0; //临时变量,当前移动的长度 var viewnum = 5; //设置每次显示图片的个数量 var movenum = 2; //每次移动的数量 var movetime = 300; //移动速度,毫秒 var scrolldiv = $(".spec-scroll .items ul"); //进行移动动画的容器 var scrollitems = $(".spec-scroll .items ul li"); //移动容器里的集合 var movelength = scrollitems.eq(0).width() * movenum; //计算每次移动的长度 var countlength = (scrollitems.length - viewnum) * scrollitems.eq(0).width(); //计算总长度,总个数*单个长度 //下一张 $(".spec-scroll .next").bind("click",function(){ if(templength < countlength){ if((countlength - templength) > movelength){ scrolldiv.animate({left:"-=" + movelength + "px"}, movetime); templength += movelength; }else{ scrolldiv.animate({left:"-=" + (countlength - templength) + "px"}, movetime); templength += (countlength - templength); } } }); //上一张 $(".spec-scroll .prev").bind("click",function(){ if(templength > 0){ if(templength > movelength){ scrolldiv.animate({left: "+=" + movelength + "px"}, movetime); templength -= movelength; }else{ scrolldiv.animate({left: "+=" + templength + "px"}, movetime); templength = 0; } } }); }); //==================图片详细页函数=====================