This repository has been archived on 2023-01-31. You can view files and clone it, but cannot push or open issues or pull requests.
sophie-lewis-hugo/layouts/partials/accordion-script.html

16 lines
427 B
HTML
Raw Normal View History

2022-12-27 07:19:29 +00:00
<script>
var acc = document.getElementsByClassName("accordion");
var i;
for (i = 0; i < acc.length; i++) {
acc[i].addEventListener("click", function() {
this.classList.toggle("active");
var panel = this.nextElementSibling;
if (panel.style.maxHeight) {
panel.style.maxHeight = null;
} else {
panel.style.maxHeight = panel.scrollHeight + "px";
}
});
}
</script>