hide older toggled elements when user toggle a new one

master
Aevann 2023-03-18 08:36:56 +02:00
parent a0ac1d25bd
commit 8ed58c1d15
1 changed files with 15 additions and 1 deletions

View File

@ -190,7 +190,21 @@ document.addEventListener("click", function(e){
if (element.dataset.toggleelement) {
document.querySelector(element.dataset.toggleelement).classList.toggle(element.dataset.toggleattr);
const toggling = document.querySelector(element.dataset.toggleelement)
const attr = element.dataset.toggleattr;
if (attr == "d-none") {
document.querySelectorAll(".toggled-visible").forEach(i => {
i.classList.add(attr)
i.classList.remove("toggled-visible")
});
}
if (toggling.classList.contains(attr)) {
toggling.classList.add("toggled-visible")
}
toggling.classList.toggle(attr);
}
});