Carousel
Rotate through elems and add/remove classes.
by Scott Currell
HTML
<p>First paragraph.</p>
<p>Second paragraph.</p>
<p>Third paragraph.</p>
<p>Fourth paragraph.</p>
<p>Fifth paragraph.</p>
<p>Sixth paragraph.</p>
<p>Seventh paragraph.</p>
<p>Eighth paragraph.</p>
<p>Nineth paragraph.</p>
<p>Tenth paragraph.</p>
JavaScript
(function addRed(elems, i, delay) {
elems.eq(i).addClass("red");
setTimeout(function() {
elems.eq(i).removeClass("red");
addRed(elems, ++i % elems.length, delay);
}, delay);
})($("p"), 0, 1000);