Multiple Image Arrays, Randomize Images On Single Button Click
As you can see, I have three arrays which store three separate images each. Currently, you can cycle through each array by mouse-clicking the image to get a new image each time. Wh
Solution 1:
You can use a randomiser function to pick a random array index:
functiongetRandomIndex(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
So in your change functions you can then do:
document.getElementById("img1").src=imgs1[getRandomIndex(0,imgs1.length - 1)];
Post a Comment for "Multiple Image Arrays, Randomize Images On Single Button Click"