MediaWiki
Foreground.js: Difference between revisions
From Grouse House Wiki
No edit summary |
No edit summary |
||
| Line 10: | Line 10: | ||
content.style.display = "none"; | content.style.display = "none"; | ||
if (this.classList.contains("active")) { | if (this.classList.contains("active")) { | ||
this. | this.classList.remove("active"); | ||
this.classList.add("hidden"); | this.classList.add("hidden"); | ||
} else { | } else { | ||
| Line 18: | Line 18: | ||
content.style.display = "block"; | content.style.display = "block"; | ||
if (this.classList.contains("hidden")) { | if (this.classList.contains("hidden")) { | ||
this. | this.classList.remove("hidden"); | ||
this.classList.add("active"); | this.classList.add("active"); | ||
} else { | } else { | ||
Revision as of 01:36, 1 February 2024
/* Collapsible Headers */
var coll = document.getElementsByClassName("c-header");
var i;
for (i = 0; i < coll.length; i++) {
coll[i].addEventListener("click", function() {
var content = this.nextElementSibling;
if (content.style.display === "block") {
content.style.display = "none";
if (this.classList.contains("active")) {
this.classList.remove("active");
this.classList.add("hidden");
} else {
this.classList.add("hidden");
}
} else {
content.style.display = "block";
if (this.classList.contains("hidden")) {
this.classList.remove("hidden");
this.classList.add("active");
} else {
this.classList.add("active");
}
}
});
}
