Jump to content

JustAnotherNewbie

Members
  • Posts

    3
  • Joined

  • Last visited

Everything posted by JustAnotherNewbie

  1. I have used the script for creating an accordion from w3Schools . I would like to add a button somwhere on the page that would collapse all that are open. Even if it is just a reload of the page which would work. <script> var acc = document.getElementsByClassName("accordion"); var i; for (i = 0; i < acc.length; i++) { acc[i].addEventListener("click", function() { this.classList.toggle("active"); var panel = this.nextElementSibling; if (panel.style.display === "block") { panel.style.display = "none"; } else { panel.style.display = "block"; } }); } </script> Please help. I am definitely a newbie. JustAnotherNewbie
  2. I have used the script for creating an accordion from w3Schools . I would like to add a button somwhere on the page that would collapse all that are open. Even if it is just a reload of the page which would work. <script> var acc = document.getElementsByClassName("accordion"); var i; for (i = 0; i < acc.length; i++) { acc[i].addEventListener("click", function() { this.classList.toggle("active"); var panel = this.nextElementSibling; if (panel.style.display === "block") { panel.style.display = "none"; } else { panel.style.display = "block"; } }); } </script> Please help. I am definitely a newbie. Linda
  3. I have used the script for creating an accordion from w3Schools . I would like to add a button somwhere on the page that would collapse all that are open. Even if it is just a reload of the page which would work. <script> var acc = document.getElementsByClassName("accordion"); var i; for (i = 0; i < acc.length; i++) { acc[i].addEventListener("click", function() { this.classList.toggle("active"); var panel = this.nextElementSibling; if (panel.style.display === "block") { panel.style.display = "none"; } else { panel.style.display = "block"; } }); } </script> Please help. I am definitely a newbie. Linda
×
×
  • Create New...