(function(e) { e.fn.menu = function(a) { var b = $.extend({}, { type: 0, defaultindex: 0, height: 5, background: "red", bottom: 0, animateease: "linear", time: 500, zindex: -1, margin: 0, antcomplete: !0, startfun: null, endfun: null }, a); a = b.type; var c = b.height, d = b.background, f = b.bottom, g = b.animateease, n = b.time, w = b.zindex, v = b.margin, p = 0, q = 0, r = 0, t = 0, l = "", h = this; e(this); var m = parseint(b.defaultindex), x = b.antcomplete, u = function() { e.isfunction(b.startfun) && b.startfun(m) }, k = h.children(); switch (a) { case 1: h.parent().css({ position: "relative", "z-index": 9 }); h.parent().append(''); h.siblings(".menuicon").css({ height: c, bottom: f, "z-index": w }); h.siblings(".menuicon").find("div").css({ height: c, background: d, marginleft: v, marginright: v }); k.each(function(a) { $(this).hasclass("hover") && (r = $(this).outerwidth(), t = $(this).position().left, l = $(this).index(), h.siblings(".menuicon").stop(!0, !1).animate({ width: r, left: t }, { duration: n, easing: g })); $(this).hover(function() { m = $(this).index(); p = $(this).outerwidth(); q = $(this).position().left; switch (x) { case !0: h.siblings(".menuicon").stop(!0, !1).animate({ width: p, left: q }, n, g, u); break; case !1: h.siblings(".menuicon").stop(!0, !1).animate({ width: p, left: q }, { duration: n, easing: g }), u() } $(this).addclass("hover").siblings().removeclass("hover") }, function() { e.isfunction(b.endfun) && b.endfun(m) }) }); k.hover(function() {}, function() { h.siblings(".menuicon").stop(!0, !1).animate({ width: r, left: t }, { duration: n, easing: g }); "" === l ? k.removeclass("hover") : k.eq(l).addclass("hover").siblings().removeclass("hover") }); break; case 0: k.each(function(a) { $(this).hasclass("hover") && (l = $(this).index()); $(this).hover(function() { m = $(this).index(); u(); $(this).addclass("hover").siblings().removeclass("hover") }, function() { e.isfunction(b.endfun) && b.endfun(m) }) }), k.hover(function() {}, function() { "" === l ? k.removeclass("hover") : k.eq(l).addclass("hover").siblings().removeclass("hover") }) } } })(jquery); /* $(".menudl").menu({ type:1,//0--无滑块(默认);1--有滑块 height:5,//滑块高度 background:"#152d79",//滑块背景色 bottom:0,//滑块距离导航底部距离 animateease:"easeoutbounce easeinoutquad",//滑块的运动轨迹 time:1000,//滑块的运动时间 margin:0,//滑块左右间距 antcomplete:true,//滑块动画完成后调函数(默认) startfun:function(i){//滑块进入后回调方法 $(".menudl dd").eq(i).find(".div_a").stop(true,true).slidedown(); }, endfun:function(i){//滑块离开后回调方法 $(".menudl dd").find(".div_a").stop(true,true).slideup() } }); */