www.lightcourse.com/public/static/home/new/js/accordion.js

22 lines
740 B
JavaScript

$(function () {
var Accordion = function (el, multiple) {
this.el = el || {};
this.multiple = multiple || false;
var links = this.el.find(".link");
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);
for (let i = 1; i < 13; i++) {
var c = new Accordion($(`#accordion${i}`), false);
}
});