Shows images one after another
Fri Mar 18 2022 12:18:39 GMT+0000 (Coordinated Universal Time)
Saved by
@Kristi
#javascript
//HTML
<img name="slide" />
//Javascript
let i = 0; // Start Point
let images = []; // Images Array
let time = 3000; // Time Between Switch
// Change Image
function changeImg() {
// Image List
images[i] = `img-${i}.jpg`;
images.length = 4;
document.slide.src = images[i];
// Check If Index Is Under Max
if (i < images.length - 1) {
// Add 1 to Index
i++;
} else {
// Reset Back To O
i = 0;
}
// Run function every x seconds
setTimeout('changeImg()', time);
}
// Run function when page loads
window.onload = changeImg;
content_copyCOPY
https://www.youtube.com/watch?v=4YQ4svkETS0
Comments