@Felix: True, jQuery is so much fun! Thanks a lot for this great solution! I'm playing around with it too :) Kling you are a king! ...Where is the '+100' button? :) – Roko C. BuljanApr 26 '11 at 13:46
@Felix kling--> argh! I have problems to stop the above on hover if THIS CONTAINER DIV have class 'stop'... may you help please?! How can i stop cycle on hover and restart on mouseout? – Roko C. BuljanApr 27 '11 at 10:01
@Felix --> Carissimo Felix, grazie x il tuo tempo e l'aiuto! here is a malfunctioning demo :) DEMO I have now problems with a false load and after click --> messy 'active' buttons :( – Roko C. BuljanApr 27 '11 at 12:48
function moveClass() {
if ($('.active:first').next()) {
$('.active:first')
.removeClass('active') //remove the current class
.next() //move to the next
.addClass('active'); // add the class to the next div
} else {
$('.active').removeClass('active');
$('.cssClass:first').addClass('active'); //move to the first of the lot if there is no more next()
}
}
$('.cssClass:first').addClass('active');
setInterval(moveClass, 5000);
Yeh was just wondering, once .next() gets to the end if it would just stop? Might need to check .next().length and make it use .first() instead, if .next().length is 0. – Chris McFarlandApr 26 '11 at 11:36
How to add a timeout before jQuery pass the active class to the second div and so on, reaching the last div and restart with the first div? and so on... (I would like to avoid the use of the jQuery Cycle plugin. Is there something simpler in a couple of lines?)jqueryShareImprove this questionFollowedited Apr 6 '13 at 23:45Kate Gregory18.5k88 gold badges5353 silver badges8585 bronze badgesasked Apr 26 '11 at 11:26Roko C. Buljan162k3232 gold badges259259 silver badges274274 bronze badgesAdd a comment