title: Cannot read property 'classList' of undefined
body: <p>I am trying to do a simple slider, but I have I this problem:</p>
  
  <pre><code>Uncaught TypeError: Cannot read property 'classList' of undefined
  </code></pre>
  
  <p>This is my code:</p>
  
  <pre><code>var div = document.querySelectorAll("div");
  
  for(var i = 0; i &lt; 6; i++){  
      div[i].onclick = function() {
          this.classList.remove("active");
          div[i+1].classList.add("active");
      }
  }
  </code></pre>
  
  <p>Can any one help me please ? </p>