export default class SimpleAccordion {
constructor(el, options) {
this.el = el;
this.options = options;
this.init();
}
handleHeaderClick(e) {
const { target } = e;
const { groupSelector, headerSelector, activeClass } = this.options;
if (target.closest(headerSelector)) {
target.closest(groupSelector).classList.toggle(activeClass);
}
}
init() {
this.el.addEventListener("click", this.handleHeaderClick.bind(this));
}
}
/*
How to use:
new SimpleAccordion(element, {
groupSelector: '',
headerSelector: '',
activeClass: ''
})
*/
Рубрики: Без рубрики
0 комментариев