could someone help me to find out why i cant click and close the open boxes
once they are open, i have to click outside to click the other, the code is here and i wrote in in vanilla javascript:
once they are open, i have to click outside to click the other, the code is here and i wrote in in vanilla javascript:
JavaScript:
const faqWrapper = document.querySelectorAll('.faq-wrapper');
const hidden = document.querySelectorAll('.hidden');
const headlines = document.querySelectorAll('.headline');
faqWrapper.forEach(wrapper => {
wrapper.addEventListener("click", (e) => {
const active = document.querySelector('.show');
if(active && active !== headlines) {
active.classList.remove("show");
}
// hidden.forEach(elements => {
// if (e.target.previousElementSibling !== elements && elements.classList.contains("show")){
// elements.classList.toggle("show");
// }
// })
const faqWrapperListChildren = wrapper.children;
const headline = faqWrapperListChildren.item(1);
headline.classList.toggle("show");
});
});