SF23103 Posted August 22, 2014 Share Posted August 22, 2014 Hello, I am using the following in a website. It displays a series of DIV's one after another. It is currently set up to rotate between 5 (including the default DIV). I want to add one more, but for the life of me can't get it to work. Although I am a HTML/CSS/PHP guy, I self admittedly am not too good with the Jquery stuff. I have changed the below highlighted numbers, but not even sure if I'm on the right track. Any help would be greatly appreciated! http://jsfiddle.net/Arj2C/ var next = 2; $(function(){ setInterval(function(){ if(next == 1) $("#4").toggleClass("hidden"); $("#" + (next-1)).toggleClass("hidden"); if(++next == 5) { //$("#4").toggleClass("hidden"); $("#" + (next-1)).toggleClass("hidden"); next = 1; } else $("#" + (next-1)).toggleClass("hidden"); }, 10000); }); Link to comment https://forums.phpfreaks.com/topic/290588-help-with-content-rotation/ Share on other sites More sharing options...
CroNiX Posted August 22, 2014 Share Posted August 22, 2014 http://jsfiddle.net/4ycg79v8/ Changes: Added class "rotator" to parent div Removed all "hidden" classes from child elements (creates by itself so less HTML to start with) Works with any number of children without additional JS changes Fixed improper child element IDs (can't start with a number) Link to comment https://forums.phpfreaks.com/topic/290588-help-with-content-rotation/#findComment-1488611 Share on other sites More sharing options...
SF23103 Posted August 23, 2014 Author Share Posted August 23, 2014 Awesome, thank you for your help. That all makes sense. Working great now. Link to comment https://forums.phpfreaks.com/topic/290588-help-with-content-rotation/#findComment-1488713 Share on other sites More sharing options...
CroNiX Posted August 23, 2014 Share Posted August 23, 2014 you're welcome Link to comment https://forums.phpfreaks.com/topic/290588-help-with-content-rotation/#findComment-1488715 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.