I created the most simple though still quite flexible jQuery slider ever! Or at least, I hope so.var slider = $(.slider-ul);slider.each(function () {    var e = $(this),        images = e.find(li),        current = null;    slide();    function slide() {        images.each(function() {            var li = $(this),                next,                pDone = false,                sDone = false;            if (li.hasClass(primary)) {                li.removeClass(primary);                pDone = true;            } else if (li.hasClass(secondary)) {                li.removeClass(secondary).addClass(primary);                next = li.next();                console.log(next);                if (next.size()) {                    next.addClass(secondary);                    sDone = true;                } else {                    images.filter(:first).addClass(secondary);                    sDone = true;                }            }            if (sDone && pDone) {                return false;            }        });        setTimeout(slide, 5000);    }});How does this look?
Super simple jQuery slider
javascript;jquery
In this code, you set sDone = true in both branches of the if-else:if (next.size()) {    next.addClass(secondary);    sDone = true;} else {    images.filter(:first).addClass(secondary);    sDone = true;}So you could move that line outside of the if-else:if (next.size()) {    next.addClass(secondary);} else {    images.filter(:first).addClass(secondary);}sDone = true;At the top you declared the current variable,but then you don't use it. If you don't need it, then remove it.