Ankit Kumar

Ankit Kumar

  • NA
  • 159
  • 48.3k

Problem with slideshow in javascript

Feb 26 2016 6:01 AM
hi all,
 
Please help me as soon as possible.
 
i am trying to put some images in array and wanna start slideshow through loop but i am not getting it done.
 
below is my code.
 
<html>
<head>
<script>
var myImage = document.getElementById("myimages");
var imageArray = ["images/image1.jpg","images/image2.png","images/image3.png","images/image4.jpg"];
var imageIndex = 0;
function changeImage()
{
for(var i=0;i<4;i++)
{
myImage.src=imageArray[0].src;
if(i==imageArray.length)
{
i=0;
}
myImage.src=imageArray[i].src;
}
}
}
</script>
</head>
<body onload="changeImage();">
<center><img src="images\image1.jpg" style="height:400px; width:400px;" id="myimages"/></center>
</body>
</html>
 

Answers (1)