Change the color of every n-element
<p>I have a for-loop which looks like this</p>

<pre><code>for(i=1; i&lt;= json.tracks.length; i++) {
$('&lt;li&gt;'+ json.tracks[i].name + '&lt;/li&gt;').appendTo('#results'); }
</code></pre>

<p>On default it run's 100 times and I want to apply a sequence of color's to it</p>

<pre><code>i = 1 --&gt; red  
i = 2 --&gt; green  
i = 3 --&gt; blue  
i = 3 --&gt; black  
i = 4 --&gt; yellow  
i = 5 --&gt; orange  

i = 6 --&gt; red  
i = 7 --&gt; green  
i = 8 --&gt; red  
...  
...
</code></pre>

<p>I tried to jquery's <strong>:nth-child()</strong> function and a modulator but both didn't really worked.</p>

<p>Is there a nice way to do it?</p>
