Hi everyone,
My javascript code is absolutely ok but its not working. I know it sounds funny but its happening with me.
Please view below code and tell me is there any mistake in it.
Javascript code:
Which change image when i click on button.
var myImages = new Array("images/ba1", "images/ba2", "images/ba3", "images/ba4", "images/ba5");
var i = 0;
function ChangeImage()
{
i++;
if(i == myImages.length)
{
i = 0;
}
document.getElementById("main").src = myImages[i]
}
Html code:
First div contains thumbnails. Second div contains large image of thumbnail. I want to change large image through javascript function.
<div>
<img src="images/a1.jpg" id="a1"/> -
<img src="images/a2.jpg" id="a2"/> -
<img src="images/a3.jpg" id="a3"/> -
<img src="images/a4.jpg" id="a4"/> -
<img src="images/a5.jpg" id="a5"/>
</div>
<input type="button" value="Next" onclick="ChangeImage()"/>
<div><img src="images/ba1.jpg" id="main"/></div>
Please anyone check my code and tell me whats the problem. It seems ok, but its not working. Images path is ok. I have to give assignment ...