if ($(".swiper-slide").length > 0) { var myswiper = new swiper('.swiper-container', { pagination: $(".banner").find(".pagination")[0], loop: true, autoplay : 6000, paginationclickable: true }); } function onmouserenterhandler() { $(".recommond .item").off("mouseenter", onmouserenterhandler); var _this = $(this); var _others = $(this).siblings(); tweenmax.to(_this, .7, { width: 420, onstart: function () { _this.addclass("active"); },oncomplete:function(){ $(".recommond .item").on("mouseenter", onmouserenterhandler); } }); tweenmax.to($(this).find(".para"), .7, {width: 205}); tweenmax.to($(this).find("img"), .7, {right: 0, autoalpha: 1}); tweenmax.to(_others, .7, { width: 125, onstart: function () { _others.removeclass("active"); } }); tweenmax.to(_others.find(".para"), .7, {width: 125}); } $(".recommond .item").on("mouseenter", onmouserenterhandler); $.fn.coneshow=function(options){ var dft={ //各种参数 各种属性 condition:"click", //触发事件的条件 点击或者滑过 prebtn:"prebtn", lens:"lens", lens_one:"lens_one", nextbtn:"prebtn", i:"i", ind_i:"ind_i", liwid:"liwid", div_dian:"div_dian", s:"s", one:"one" } var ops = $.extend(dft,options); this.each(function(){ var a=dft.ind_i; //实现功能的代码 var cthis=$(this) var j=true; cthis.css("width",dft.liwid*dft.lens+"px"); dft.lens=math.ceil(dft.lens/dft.lens_one)-dft.one; var timmer=setinterval(show,dft.s); dft.prebtn.bind("click",function(){ j=false; show(); }) dft.nextbtn.bind("click",function(){ show(); }) dft.div_dian.find("span").bind("click",function(){ dft.i=$(this).index()-1; show(); }) $(this).hover(function(){ clearinterval(timmer); },function(){ timmer=setinterval(show,dft.s); }) function show(){ if(j) { dft.i++; if(dft.i>dft.lens-dft.ind_i) { dft.i=0; } } else { dft.i--; if(dft.i<0) { dft.i=dft.lens-dft.ind_i; } j=true; } cthis.stop().animate({"left":-dft.liwid*dft.i+"px"},500); dft.div_dian.find("span:eq("+dft.i+")").addclass("on").siblings().removeclass("on"); } }); }