title: Cannot read property 'classList' of null and overlays
body: <p>kind of stuck here..</p>
  
  <p>So I have these button accordions which I'm going to fill with content but this will do for now. The panels will be filled with content when I get the functions up and working. All the panels display when the button is being pressed <strong>EXCEPT</strong> for the first accordion. I checked the console and came up with this error:<em>"Cannot read property 'classList' of null"</em>. Any ideas on what to do? Tried to change the script somehow, but didn't seem to work. </p>
  
  <p>Another thing that I can't seem to get working are my panel overlays. I want my panel overlays to cover up the rest of the content on the page, whenever a button is being pressed. The button should be active so it can go back to its original theme. I tried to fix it with some "z-index" but didn't seem to quite respond. I also have a script where I tried to make the buttons in my container active but didn't worked out. </p>
  
  <p>Any suggestions?   </p>
  
  <p>Here's my code so far: </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 acc = document.getElementsByClassName("accordion");
  var i;
  
  for (i = 0; i &lt; acc.length; i++) {
    acc[i].onclick = function() {
  
      this.nextElementSibling.classList.toggle("show");
    }
  }</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>html,
  body {
    width: 80%;
    margin: 0 auto;
  }
  
  head {
    text-align: left;
  }
  
  .container {
    width: 100%;
    margin: 0 auto;
  }
  
  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;
    margin-top: 2%;
  }
  
  button h3 {
    text-align: center;
  }
  
  button.accordion.active,
  button.accordion:hover {
    background-color: #ddd;
  }
  
  div.panel {
    padding: 0 18px;
    background-color: white;
    max-height: 0;
    overflow: hidden;
    transition: 0.6s ease-in-out;
    opacity: 0;
  }
  
  div.panel.show {
    opacity: 1;
    max-height: 700px;
  }
  
  .container div.active {
    height: 100%;
    margin-top: 10%;
    margin-bottom: 5%;
    background-color: white;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 2;
    transition-duration: 1s;
    align-items: center;
  }
  
  @media only screen and (max-width: 500px) {
    .container {
      width: 100%;
      margin: 0 auto;
    }
    button.accordion {
      background-color: #eee;
      color: #444;
      cursor: pointer;
      padding: 7px;
      width: 100%;
      border: none;
      text-align: left;
      outline: none;
      font-size: 15px;
      transition: 0.4s;
      margin: 2%;
    }
    button.accordion.active,
    button.accordion:hover {
      background-color: #ddd;
    }
    div.panel {
      padding: 0 18px;
      background-color: white;
      max-height: 0;
      overflow: hidden;
      transition: 0.6s ease-in-out;
      opacity: 0;
    }
    div.panel.show {
      opacity: 1;
      max-height: 700px;
    }
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"&gt;&lt;/script&gt;
  &lt;div class="container"&gt;
  
    &lt;button class="accordion"&gt;&lt;h3&gt;Random 1&lt;/h3&gt;&lt;/div&gt;&lt;/button&gt;
  
    &lt;div class="panel"&gt;
  
      &lt;h1&gt; hej &lt;/h1&gt;
  
    &lt;/div&gt;
  
    &lt;button class="accordion"&gt;&lt;h3&gt;Random 2&lt;/h3&gt;&lt;/div&gt;&lt;/button&gt;
  
    &lt;div class="panel"&gt;
  
      &lt;h1&gt; hej &lt;/h1&gt;
  
    &lt;/div&gt;
  
    &lt;button class="accordion"&gt;&lt;h3&gt;Random 3&lt;/h3&gt;&lt;/div&gt;&lt;/button&gt;
  
    &lt;div class="panel"&gt;
  
      &lt;h1&gt; hej &lt;/h1&gt;
  
    &lt;/div&gt;
  
    &lt;button class="accordion"&gt;&lt;h3&gt;Random 4&lt;/h3&gt;&lt;/div&gt;&lt;/button&gt;
  
    &lt;div class="panel"&gt;
  
      &lt;h1&gt; hej &lt;/h1&gt;
  
    &lt;/div&gt;
  
    &lt;button class="accordion"&gt;&lt;h3&gt;Random 5&lt;/h3&gt;&lt;/div&gt;&lt;/button&gt;
  
    &lt;div class="panel"&gt;
  
      &lt;h1&gt; hej &lt;/h1&gt;
  
    &lt;/div&gt;
  
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>