I've 3 divs that i want to highlight (with a css class) one after each other.After that the loop restarts and should do the same thing. But it isn't working.
Here's the fiddle http://jsfiddle.net/gamito/6M65S/
This must be something obvious ...
<script>
$('.ticker').each(function(i) {
var elem = $(this);
var prev = $(this).prev();
setTimeout(function() {
elem.addClass("selected");
prev.removeClass("selected");
}, i * 2000);
});
</script>
setIntervalinstead. Plus I think the logic is missing something. How do you know when it reaches the end? Why useeach()?