Possible Duplicate:
How do I add a delay in a JavaScript loop?
How can one delay after the completion of each iteration (or before) in a javascript for loop? Here is my code, but I need to have it 'sleep' for 6 seconds once it sets the color before it moves on to the next one in the list.
for (i = 0; i < switchers.length; i++) {
$('#switchers ol li:nth-child(' + (i+1) + ')').css('color', 'green');
}
I have tried nesting a setTimeout, but that failed to work, and after searching around google, I decided to ask it here.