$.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]);
// })
$("#box li").each(function (index, ele) {
$(ele).css("backgroundImage","url(images/"+(index+1)+".jpg)");
})
//获取当前显示800的那个宽度 : 总宽度 - width*剩下四个li的长度
var maxLength=this.width()-width*($li.length-1)
//计算240的宽度 即平均宽度
var vagLength=this.width()/$li.length;
$li.mouseenter(function () {
$(this).stop().animate({width:maxLength}).siblings().stop().animate({width:width})
})
$li.mouseleave(function () {
$li.stop().animate({width:vagLength})
})
}
query手风琴插件封装函数
最新推荐文章于 2022-06-29 02:12:01 发布