MediaWiki

Foreground.js: Difference between revisions

From Grouse House Wiki

No edit summary
No edit summary
Line 9: Line 9:
     if (content.style.display === "block") {
     if (content.style.display === "block") {
       content.style.display = "none";
       content.style.display = "none";
       this.classList.add("hidden");
       if (this.classList.contains("active")) {
        this.class.remove("active");
        this.classList.add("hidden");
      } else {
        this.classList.add("hidden");
      }
     } else {
     } else {
       content.style.display = "block";
       content.style.display = "block";
       this.classList.add("active");
       if (this.classList.contains("hidden")) {
        this.class.remove("hidden");
        this.classList.add("active");
      } else {
        this.classList.add("active");
      }
     }
     }
   });
   });
}
}

Revision as of 01:13, 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.class.remove("active");
         this.classList.add("hidden");
      } else {
         this.classList.add("hidden");
      }
    } else {
      content.style.display = "block";
      if (this.classList.contains("hidden")) {
         this.class.remove("hidden");
         this.classList.add("active");
      } else {
         this.classList.add("active");
      }
    }
  });
}