JSFiddle - React, Tailwind, and code Playground
by Shishir Max
HTML
<body onload='changeimage(2)'>
<div style='position:absolute;width:100%;height:100%;left:0px;top:0px;' align='center'><img width='150px' height='100px' id='myimage' src='http://www.photos.a-vsp.com/fotodb/14_green_cones.jpg' /></div>
</body>
JavaScript
var imageID = 0;
function changeimage(every_seconds) {
//change the image
if (!imageID) {
document.getElementById("myimage").src = "1.png";
imageID++;
} else {
if (imageID == 1) {
document.getElementById("myimage").src = "2.png";
imageID++;
} else {
if (imageID == 2) {
document.getElementById("myimage").src = "3.png";
imageID = 0;
}
}
}
//call same function again for x of seconds
setTimeout("changeimage(" + every_seconds + ")", ((every_seconds) * 1000));
}