Created
January 21, 2011 04:16
-
-
Save chestone/789237 to your computer and use it in GitHub Desktop.
A div with an id of 'slideshow' contains five images, the first of which is shown and the others are hidden using a display style of none. Using Javascript, create a simple slideshow that cycles through the images, displaying each image for three seconds
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var imgs = document.getElementById('slideshow').getElementsByTagName('img'); | |
var currIdx = 0; | |
setInterval(function() { | |
imgs[currIdx].style.display = 'none'; | |
currIdx = (currIdx + 1 == imgs.length) ? 0 : currIdx + 1; | |
imgs[currIdx].style.display = ''; | |
}, 3000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment