Auto Rotating Slide Show

Submitted by:Pitter Alderson

Date added:05 February, 2014

Category:JavaScript

We created a slide show that allowed the user to move through an array of images.

Tags: auto rotating , slide show

Code Snippet:

    <script language="JavaScript" type="text/javascript">  
var images = new Array('morning.jpg','afternoon.jpg','night.jpg','lightbulb_on.jpg')
var count = -1

function slideShow(){

if (count <=2){
count ++;
}

document.getElementById("show").innerHTML = "<img src="images/"+images[count]+"">"
setTimeout("slideShow()", 3000)
}
</script>
<div id="show">
<script>slideShow()</script>
</div>
 
 

Comments