Okay so I have an image (id = "slideshow") in my content section of my site. I'm trying to create a loop that alternates the image src using JQuery. Here is the code I have so far. It seems to loop through but the only src change that it shows is the last one. As a result glossy.jpg is the only image I see. I know it must be working to some extent seeing as glossy.jpg is not the original src that I have set. Once I get each picture to show I'll tidy up the rest of the code. Any answers are much appreciated =)
$(document).ready(function() {
for (i = 1; i <= 100; i++){
$("#slideshow").attr("src", "Images/image1.jpg").fadeTo(3000, 1.00);
$("#slideshow").fadeTo("slow", 0.00);
$("#slideshow").attr("src", "Images/image2.jpg").fadeTo(3000, 1.00);
$("#slideshow").fadeTo("slow", 0.00);
$("#slideshow").attr("src", "Images/glossy1.jpg").fadeTo(3000, 1.00);
$("#slideshow").fadeTo("slow", 0.00);
}
});
Consider this code for an image rota tor that you are making.
And this would be the HTML
Since you could utilize arrays while storing URL's into them and then so the same rotation using
setInterval()
function.Referance : www.burnmind.com