title: If Previous Content Div is Open, Close It and Open the Next (Plain JavaScript)
body: <p>I have this simple dropdown faq system, I only want one content div to be open at a time, so I tried to use an if / else condition, but I can only make it work halfway. </p>
  
  <ol>
  <li><p>I'm checking if the content div next to the trigger div has class is-visible — if not, add that class (this works)</p></li>
  <li><p>But if the previous content div has (contains) class is-visible, I want to remove it, so only one content div is open at a time. </p></li>
  </ol>
  
  <p>I've tried so many different conditions but I think I'm overcomplexifying it, this should be simple enough right? </p>
  
  <p><a href="https://jsfiddle.net/notuhm05/1/" rel="nofollow">https://jsfiddle.net/notuhm05/1/</a></p>
  
  <pre><code>var faqTrigger = document.querySelectorAll('.mm-faq-trigger');
  for (var i = 0; i &lt; faqTrigger.length; i++) {
      faqTrigger[i].addEventListener('click', function() {
        if (!this.nextElementSibling.classList.contains('is-visible')) {
          this.nextElementSibling.classList.add('is-visible');
        } else if (this.previousElementSibling.classList.contains('is-visible')) {
          this.nextElementSibling.classList.remove('is-visible');
        } else {
          console.log("doesn't work");
        }
      });
  }
  </code></pre>
  
  <p>Would greatly appreciate some pointers here! :-)</p>