19 lines
551 B
JavaScript
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'
|
|
}
|
|
})
|
|
}
|