Skip to content

Instantly share code, notes, and snippets.

View chestone's full-sized avatar
🐈
Is Cat

Cheston Lee chestone

🐈
Is Cat
View GitHub Profile
@chestone
chestone / akornSlideShow
Created March 10, 2011 23:18
Slideshow from Alex Korn.
setInterval(function(imgs, currIdx) {
return function() {
imgs[currIdx].style.display = 'none';
currIdx = (currIdx + 1 == imgs.length) ? 0 : currIdx + 1;
imgs[currIdx].style.display = '';
};
}(document.getElementById('slideshow').getElementsByTagName('span'), 0), 3000);
@chestone
chestone / SlideShow.js
Created January 21, 2011 04:16
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
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);