Applying a class from an array to a repeated item with JQuery
<p>I know I'm close here but it only adds a class from the colors array to the 1st 3 postbox divs:</p>

<pre><code>$(document).ready(function($) {

    var toCopy = $('.postbox');
    var colors = ['box1','box2','box3'];

    for (var i = 1;i &lt; 7;i++) {
        $('.rightCol').append(toCopy.clone());
    }

    $('.postbox').each(function(i, val) {
        $(this).addClass(colors[i]);
    });

});
</code></pre>

<p>Here's the end result using the above:</p>

<pre><code>&lt;div class="rightCol"&gt;
    &lt;div class="postbox box1"&gt;&lt;/div&gt;
    &lt;div class="postbox box2"&gt;&lt;/div&gt;
    &lt;div class="postbox box3"&gt;&lt;/div&gt;
    &lt;div class="postbox"&gt;&lt;/div&gt;
    &lt;div class="postbox"&gt;&lt;/div&gt;
    &lt;div class="postbox"&gt;&lt;/div&gt;
    &lt;div class="postbox"&gt;&lt;/div&gt;
&lt;/div&gt;
</code></pre>

<p>How do I get it to keep repeating? </p>
