I have a few separate headings:
<h3 class="ads">First</h3>
<h3 class="ads">Second</h3>
<h3 class="ads">Third</h3>
And I'd like to be able to continuously loop over them, changing the text from black to red, and then back to black once the next heading has changed to red.
Here's what I have so far: it works once, however I cannot get it to re-loop succesfully:
$('.ads').each(function(i) {
var el=$(this);
setTimeout(function() {
el.prevAll('.ads').css('color','black');
el.css('color', 'red');
}, i * 3000);
});
I'd like to be able to manually set how long I wait in between each change, so an explanation would help a lot too!
setIntervalrather thansetTimeoutfor starters maybe.