I am trying to set up collapsible divs. They work fine, but when I open another collapsible div, the opened ones wont close unless I manually close them one by one.

How can automatically make an opened collapsible div when opening a different one?

HTML

```
<html>
  <button type="button" class="collapsible">BUTTON</button>
  <div class="content">
    <p style="padding: 20px 0;">CONTENT</p>
  </div>
  <button type="button" class="collapsible">BUTTON</button>
  <div class="content">
    <p style="padding: 20px 0;">CONTENT</p>
  </div>
  <button type="button" class="collapsible">BUTTON</button>
  <div class="content">
    <p style="padding: 20px 0;">CONTENT</p>
  </div>
</html>

```

JS

```
var coll = document.getElementsByClassName("collapsible");
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.maxHeight){
      content.style.maxHeight = null;
    } else {
      content.style.maxHeight = content.scrollHeight + "px";
    }
  });
}

```