calling setTimeout with a for loop
<p>I've written a function that changes the css positioning of a div</p>

<p>I've been successfully using setTimeout to call the function at a specific interval</p>

<p>NOW what I'm trying to do is call the function on 28 different divs on the same page, each with its own speed.</p>

<p>my thinking was that I could do this with a for loop like so:</p>

<pre><code>for (var x = 0; x &lt; 28; x++)
   { setInterval(function(){changeDirection(divlist[x])}, divs[divlist[x]].speed);}
</code></pre>

<p>using the object 'divs' where the speed and id  are stored</p>

<p>the only way I could get them all to move against the timer was to call setInterval 28 times like so...</p>

<pre><code>setInterval(function(){changeDirection(divlist[1])}, divs[divlist[1]].speed);
setInterval(function(){changeDirection(divlist[2])}, divs[divlist[2]].speed);
setInterval(function(){changeDirection(divlist[3])}, divs[divlist[3]].speed);
setInterval(function(){changeDirection(divlist[4])}, divs[divlist[4]].speed);....etc
</code></pre>

<p>the for loop did NOT work...</p>

<p>does anyone have any idea why? and is there a way to call setInterval on many different functions with a loop like this</p>
