For example, if I open AAA then open CCC the AAA closes at the same time. One accordion opened at a time basically. Is it also possible that when you search it's automatically closed (When you open BBB its closed when you searched for it)
Here is the sample https://jsfiddle.net/szt20con/
var acc = document.getElementsByClassName("accor");
var panel = document.getElementsByClassName('panel');
for (var 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";
}
});
}