Estrutura


.accordion {
background-color: #0275d8;
color: #444;
cursor: pointer;
padding: 18px;
width: 100%;border: none;
text-align: left;
outline: none;
font-size: 15px;
transition: 0.4s;
}
.accordion:after {
content: ‘\002B’;
color: #ffffff;
font-weight: bold;
float: right;
margin-left: 5px;
}
.active:after {
content: “\2212”;
}
.sub{
background-color: #91b4cc;
color: #ffffff;
cursor: pointer;
padding: 18px;
width: 100%;
border: none;
text-align: left;
outline: none;
font-size: 15px;
}

.active, .accordion:hover {
background-color: #91b4cc;
}

.panel {
padding: 0 18px;
display: none;
background-color: white;
overflow: hidd

const acc = document.getElementsByClassName(“accordion”);
let i;

for (let y = 0; y < 5; y++) {
for (let x = 0; x < acc.length; x++) {
if ((acc[x].nextElementSibling.nodeName === “BUTTON”) || (acc[x].nextElementSibling.nodeName === “A”)) {
acc[x].setAttribute(‘class’, ‘sub’)
}
}
}
for (i = 0; i < acc.length; i++) {
acc[i].addEventListener(“click”, function () {
this.classList.toggle(“active”);
const panel = this.nextElementSibling;
if (panel.style.display === “block”) {
panel.style.display = “none”;
} else {
panel.style.display = “block”;
}
});
}