Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 12111

How to make accordion close when other is open

$
0
0

I need help with some elementor accordion...

This is my code:

jQuery(document).ready(function () {    jQuery('.elementor-tab-title').click(function () {        let active = document.querySelectorAll(".elementor-tab-title elementor-active");        for(let j = 0; j < active.length; j++){         active[j].classList.remove("elementor-active");         active[j].nextElementSibling.style.maxHeight = null; //or 0px        }    });});

So, area-selected and area-expanded is switching to false when is closed and to true when its opened.

Class is switching from 'elementor-tab-title' when closed to 'elementor-tab-title elementor-active' when opened.

There are 6 of them, and I just can't figure out how to make them close when another is clicked to open.

Any help is appreciated. Thank you!


Viewing all articles
Browse latest Browse all 12111

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>