forked from autonomic-cooperative/sophie-lewis-hugo
writing: add accordion functionality
This commit is contained in:
16
layouts/partials/accordion-script.html
Normal file
16
layouts/partials/accordion-script.html
Normal file
@ -0,0 +1,16 @@
|
||||
<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>
|
Reference in New Issue
Block a user