How to add class to multiple divs with same class, javascript? : <p>I have multiple classes with same class name, for example I have 10 classes that have class name test. I want to add new class, for example active, for each class.</p>

<p>So if I have this:</p>

<pre><code>&lt;div class="test"&gt;&lt;/div&gt;
&lt;div class="test"&gt;&lt;/div&gt;
&lt;div class="test"&gt;&lt;/div&gt;
&lt;div class="test"&gt;&lt;/div&gt;
</code></pre>

<p>multiple times on page. How to add to each class active, so it looks like this</p>

<pre><code>&lt;div class="test active"&gt;&lt;/div&gt;
&lt;div class="test active"&gt;&lt;/div&gt;
&lt;div class="test active"&gt;&lt;/div&gt;
&lt;div class="test active"&gt;&lt;/div&gt;
</code></pre>
