I have simple html and Javascript code shown below where image1 is displayed, and when it is clicked it changes to image2. I am having a problem extending this to a third image such that if image2 is clicked, it changes to image3 and finally if image3 is clicked that it returns to image1 and the cycle can be repeated once more. Can anyone suggest to me what the best approach is because I think that the way I am currently doing it for 2 images won't work for what I have described. Thanks
Note:This is a problem I have encountered for exam preparation and as such I can't use JQuery-must be JavaScript.
<html>
<head>
<script>
function preloadImages() {
Image1=new Image();
Image1.src = "image1.jpg";
}
</script>
</head>
<body onLoad="preloadImages();">
<img name="myButton" src="image2.jpg"
onClick="document.myButton.src='image1.jpg';"
onClick="document.myButton.src='image2.jpg';">
</body>
</html>