Lensmeister
Coder
Afternoon all,
What I need is instead of clicking the image to move to the next image I want to be able to chose to click on text "Image 1" or "Image 2" or "Image 3" to be able to be able reveal those images.
On some pages there maybe the need for just one image or up to five images.
Sometimes they may be .gig or .png files. That should be ok to to change the file types in the Var Images section ... correct ? ?
Thanks in advance,
What I need is instead of clicking the image to move to the next image I want to be able to chose to click on text "Image 1" or "Image 2" or "Image 3" to be able to be able reveal those images.
On some pages there maybe the need for just one image or up to five images.
Sometimes they may be .gig or .png files. That should be ok to to change the file types in the Var Images section ... correct ? ?
Thanks in advance,
HTML:
<!DOCTYPE html>
<html>
<head>
<script>
var images = ['image1.jpg', 'image2.jpg', 'image3.jpg'];
for (var j = images.length; j--;) {
var img = new Image();
img.src = images[j];
}
</script>
</head>
<body>
This is the test page<br />
<img id="myButton" src="image2.jpg" width="50%"/>
<br />
Image 1 <br />
Image 2 <br />
Image 3 <br /><br />
What I need is instead of clicking the image to move to the next image I want to be able to chose to click on text "Image 1" or "Image 2" or "Image 3" to be able to be able reveal those images.
<br />
On some pages there maybe the need for just one image or upto five images.<br />
Sometimes they may be .gig or .png files. That should be ok to to change the file types in the Var Images section ... correct ? ?
<script type="text/javascript">
var i = 1; // Initialize the index for the current image
// Add an event listener to the image
document.getElementById('myButton').addEventListener('click', function() {
// Toggle to the next image in the array
this.src = images[i >= images.length - 1 ? i = 0 : ++i];
}, false);
</script>
</body>
</html>
Last edited by a moderator: