Files
website/assets/js/accordion.js
T
2022-07-07 11:54:43 +02:00

19 lines
551 B
JavaScript

var acc = document.getElementsByClassName('accordion')
var i
for (i = 0; i < acc.length; i++) {
acc[i].addEventListener('click', function () {
/* Toggle between adding and removing the "active" class,
to highlight the button that controls the panel */
this.classList.toggle('active')
/* Toggle between hiding and showing the active panel */
var panel = this.nextElementSibling
if (panel.style.maxHeight) {
panel.style.maxHeight = null
} else {
panel.style.maxHeight = panel.scrollHeight + 'px'
}
})
}