I am trying to modify the script below to slideshow/rotate through a handful of text DIVs.
I need these DIVs to appear in order-- div 1, then div 2, then div 3. Each would appear for 5 seconds, then show the next div... but in order.
The script below works well for Random divs, but I need them to be in order-- div 1, div 2, div 3... each time.
Code:<div id="d1" style="display:none;">some text 1</div> <div id="d2" style="display:none;">some text 2</div> <div id="d3" style="display:none;">some text 3</div> <script type="text/javascript"> divs = ['d1','d2','d3']; function hideDivs() { for (var i=0; i<divs.length; i++) document.getElementById(divs[i]).style.display = 'none'; } function showDiv() { hideDivs(); //hide them all before we show the next one. var randomDiv = divs[Math.floor(Math.random()*divs.length)]; var div = document.getElementById(randomDiv).style.display = 'block'; setTimeout(showDiv,500); //set a delay before showing the next div } showDiv(); </script>


Reply With Quote

Bookmarks