title: JavaScript accordion on Google Sites (classic)
body: <p>I'm trying to create a FAQ accordion on a classic Google Sites page but unable to determine the best route.</p>
  
  <p>The closest I've got was copying the example in w3schools.com in to an HTML gadget (code below). However, the panel doesn't seem to expand and I don't quite understand the part of the code either.</p>
  
  <p>I've also tried hosting a custom gadget but Google has become very strict on that and couldn't figure out how to host.</p>
  
  <p>Here's a test page with the code:
  <a href="https://sites.google.com/a/cartomark.com/test/" rel="nofollow noreferrer">https://sites.google.com/a/cartomark.com/test/</a></p>
  
  <p>Here's the code:</p>
  
  <pre><code>&lt;style&gt;
  button.accordion {
  background-color: #eee;
  color: #444;
  cursor: pointer;
  padding: 18px;
  width: 100%;
  border: none;
  text-align: left;
  outline: none;
  font-size: 15px;
  transition: 0.4s;
  }
  
  button.accordion.active, button.accordion:hover {
      background-color: #ddd;
  }
  
  button.accordion:after {
      content: '\002B';
      color: #777;
      font-weight: bold;
      float: right;
      margin-left: 5px;
  }
  
  button.accordion.active:after {
      content: "\2212";
  }
  
  div.panel {
      padding: 0 18px;
      background-color: white;
      max-height: 0;
      overflow: hidden;
      transition: max-height 0.2s ease-out;
  }
  &lt;/style&gt;
  &lt;h2&gt;Accordion with symbols&lt;/h2&gt;
  &lt;p&gt;In this example we have added a "plus" sign to each button. When the user clicks on the button, the "plus" sign is replaced with a "minus" sign.&lt;/p&gt;
  &lt;button class="accordion"&gt;Section 1&lt;/button&gt;
  &lt;div class="panel"&gt;
    &lt;p&gt;Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.&lt;/p&gt;
  &lt;/div&gt;
  
  &lt;button class="accordion"&gt;Section 2&lt;/button&gt;
  &lt;div class="panel"&gt;
    &lt;p&gt;Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.&lt;/p&gt;
  &lt;/div&gt;
  
  &lt;button class="accordion"&gt;Section 3&lt;/button&gt;
  &lt;div class="panel"&gt;
    &lt;p&gt;Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.&lt;/p&gt;
  &lt;/div&gt;
  
  &lt;script&gt;
  var acc = document.getElementsByClassName("accordion");
  var i;
  
  for (i = 0; i &lt; acc.length; i++) {
    acc[i].onclick = function() {
      this.classList.toggle("active");
      var panel = this.nextElementSibling;
      if (panel.style.maxHeight){
        panel.style.maxHeight = null;
      } else {
        panel.style.maxHeight = panel.scrollHeight + "px";
      } 
    }
  }
  &lt;/script&gt;
  </code></pre>