title: Close all collapsible content at once
body: <p>I have the following code:</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var coll = document.getElementsByClassName("collapsible");
  var i;
  
  for (i = 0; i &lt; coll.length; i++) {
      coll[i].addEventListener("click", function() {
          this.classList.toggle("active");
          var content = this.nextElementSibling;
          if (content.style.maxHeight) {
              content.style.maxHeight = null;
          } else {
              content.style.maxHeight = content.scrollHeight + "px";
          }
      });
  }</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>.content    {
      max-height:0;
      overflow:hidden;
      transition:max-height 0.2s ease-out;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;button class="collapsible"&gt;First question&lt;/button&gt;
  &lt;div class="content"&gt;First answer&lt;/div&gt;
  
  &lt;button class="collapsible"&gt;Second question&lt;/button&gt;
  &lt;div class="content"&gt;Second answer&lt;/div&gt;
  
  &lt;button class="collapsible"&gt;Close all collapsible content&lt;/button&gt;</code></pre>
  </div>
  </div>
  </p>
  <p>There are two collapsible buttons called <code>First question</code> and <code>Second question</code>. You click on one of them to show the content and you click again to hide the content.</p>
  <p>If you opened multiple collapsible contents you have to click on each of them to close all. I need a button that allows to close all at once.</p>
  <p>But I don't know how to tell the javascript code not to close only one but every content.</p>
  <p>Do you know how I can do that?</p>