Por ejemplo, si abro AAA y luego abro CCC, AAA se cierra al mismo tiempo. Básicamente, se abrió un acordeón a la vez. ¿También es posible que cuando busca se cierre automáticamente (cuando abre BBB, se cierra cuando lo buscó)
Aquí está la muestra 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"; } }); }