writing: add accordion functionality

This commit is contained in:
desmukh
2022-12-27 12:19:29 +05:00
parent 5207ecca45
commit 9135a41cd6
4 changed files with 62 additions and 6 deletions

View 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>