Program:
Output:
<html>
<head>
<script>
var i , imgs , pic ;
function init()
{
pic = document.getElementById("p");
imgs = ["logo.png","submit.jpg","reset.jpg"];
i=0;
rotate();
}
function rotate()
{
pic.src=imgs[i];
(i==(imgs.length-1))?i=0:i++;
setTimeout(rotate,2000);
}
document.addEventListener("DOMContentLoaded",init,false);
</script>
</head>
<body>
<img id="p" width="120" height="200" src="logo.png">
</body>
</html>
Output:
