MediaWiki
Foreground.js: Difference between revisions
From Grouse House Wiki
(Created page with "→Collapsible Headers on Desktop: var coll = document.getElementsByTagName('h2'); var i; for (i = 0; i < coll.length; i++) { coll[i].addEventListener("click", function() { this.classList.toggle("active"); var content = this.nextElementSibling; if (content.style.display === "block") { content.style.display = "none"; } else { content.style.display = "block"; } }); }") |
No edit summary |
||
Line 6: | Line 6: | ||
for (i = 0; i < coll.length; i++) { | for (i = 0; i < coll.length; i++) { | ||
coll[i].addEventListener("click", function() { | coll[i].addEventListener("click", function() { | ||
this.classList.toggle("active"); | |||
var content = this.nextElementSibling; | |||
if (content.style.display === "block") { | |||
content.style.display = "none"; | |||
} else { | |||
content.style.display = "block"; | |||
} | |||
}); | |||
} | |||
var coll2 = document.getElementsByClassName('coll-header'); | |||
var i2; | |||
for (i2 = 0; i2 < coll2.length; i2++) { | |||
coll2[i2].addEventListener("click", function() { | |||
this.classList.toggle("active"); | this.classList.toggle("active"); | ||
var content = this.nextElementSibling; | var content = this.nextElementSibling; |
Revision as of 01:39, 30 January 2024
/* Collapsible Headers on Desktop */ var coll = document.getElementsByTagName('h2'); var i; for (i = 0; i < coll.length; i++) { coll[i].addEventListener("click", function() { this.classList.toggle("active"); var content = this.nextElementSibling; if (content.style.display === "block") { content.style.display = "none"; } else { content.style.display = "block"; } }); } var coll2 = document.getElementsByClassName('coll-header'); var i2; for (i2 = 0; i2 < coll2.length; i2++) { coll2[i2].addEventListener("click", function() { this.classList.toggle("active"); var content = this.nextElementSibling; if (content.style.display === "block") { content.style.display = "none"; } else { content.style.display = "block"; } }); }