I would like to show divs at a specific interval (10 seconds) and show next div and as go on and repeat the same.
**
Sequence :
**
On 10th second
show div1 , hide other divs ,
After 5seconds interval
Show div 2 and hide other divs,
After 5 seconds interval
Show div 3 and hide other divs,
and repeat the same for every 10 seconds.
Code Follows:
<div id='div1' style="display:none;">
<!-- content -->
</div>
<div id='div2' style="display:none;">
<!-- content -->
</div>
<div id='div3' style="display:none;">
<!-- content -->
</div>
See InnerFade.
Loop through divs every 10 seconds.
Try this
Heres a another take on this problem, using recursion and without using mutable variables. Also, im not using
setInterval
so theres no cleanup that has to be done.Having this HTML
Using ES2016
Here you call the function recursively and update the arguments.
Working Example here - add /edit to the URL to play with the code
You just need to use JavaScript
setInterval
functionand the HTML
EDIT:
In response to your comment about the container div, just modify this
to this
here is a jQuery plugin I came up with:
You need to have a common classname for all the divs you wan to cycle, use it like this: