$.fn.accordion=function (colors,width) {
//如果用户没有传参数,可以设置默认值
colors=colors||[];
width=width||20;
//让当前的对象去找li
var $li=this.find("li");
//渲染颜色
$li.each(function (index,ele) {
$(ele).css("backgroundColor",colors[index])
})
//获取当前显示800的那个宽度=总宽度-width*剩下四个li的长度
var maxLength=this.width()-width*($li.length-1);
//计算240的宽度
var avgLength=this.width()/$li.length;
$li.mouseenter(function () {
$(this).stop().animate({width:maxLength}).siblings().stop().animate({width:width});
})
$li.mouseleave(function () {
$li.stop().animate({width:avgLength});
})
}
封装的jquery手风琴插件
最新推荐文章于 2019-06-20 19:50:35 发布