Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script>
- var accordions = document.getElementsByClassName("accordion");
- for (var i = 0; i < accordions.length; i++) {
- accordions[i].onclick = function() {
- this.classList.toggle('is-open');
- var content = this.nextElementSibling;
- if (content.style.maxHeight) {
- // accordion is currently open, so close it
- content.style.maxHeight = null;
- } else {
- // accordion is currently closed, so open it
- content.style.maxHeight = content.scrollHeight + "px";
- }
- }
- }
- </script>
Add Comment
Please, Sign In to add comment