$(function() {
var Accordion = function(el, multiple) {
this.el = el || {};
this.multiple = multiple || false;
// Variables privadas
var links = this.el.find('.link');
// Evento
links.on('click', {el: this.el, multiple: this.multiple}, this.dropdown)
}
Accordion.prototype.dropdown = function(e) {
var $el = e.data.el;
$this = $(this),
$next = $this.next();
$next.slideToggle();
$this.parent().toggleClass('open');
if (!e.data.multiple) {
$el.find('.submenu').not($next).slideUp().parent().removeClass('open');
};
}
var accordion = new Accordion($('#accordion'), false);
});
有几处不明白的,麻烦大大们解答下
- var Accordion = function(el, multiple),这个函数传的第二个参数有什么作用?
- links.on('click', {el: this.el, multiple: this.multiple}, this.dropdown) 中间那句花括号起到什么作用了?
- var $el = e.data.el; e.data.el是什么意思?有啥作用
- $el.find('.submenu').not($next).slideUp().parent().removeClass('open'); 最后这句话not是干嘛用的,为啥要这样写呢
这个效果来自jquery插件库的这个插件 http://www.jq22.com/jquery-info810 |