title: How to remove multiple divs with same class from HTML page
body: <p>I have a container div that contains some text and multiple divs all with class 'test', and I am trying to delete all the divs with class 'test' using pure javascript.</p>
  
  <p>Currently, I have a variable containing all the divs with class 'test' which I have iterated through to remove each one.</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 divsToRemove = document.getElementsByClassName("test");
  for (var i = 0; i &lt; divsToRemove.length; i++) {
    divsToRemove[i].remove();
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div id="container"&gt;
    &lt;p&gt;This text should stay&lt;/p&gt;
    &lt;div class="test"&gt;
      &lt;p&gt;Testing 1&lt;/p&gt;
    &lt;/div&gt;
    &lt;div class="test"&gt;
      &lt;p&gt;Testing 2&lt;/p&gt;
    &lt;/div&gt;
    &lt;div class="test"&gt;
      &lt;p&gt;Testing 3&lt;/p&gt;
    &lt;/div&gt;
    &lt;div class="test"&gt;
      &lt;p&gt;Testing 4&lt;/p&gt;
    &lt;/div&gt;
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>I expected all of the divs with class 'test' to be removed, but only some of them have been removed with this code</p>