I’m unsure if fadeIn is even the right transition (newbie), but I’m basically trying to have a crossfade between homepage images that change every 3 seconds. The changing is working successfully, but I don’t know how to get them to fade. Currently there is just an abrupt switch. Here is my code:
var images = ["image-link1", "image-link2"];
$(function () {
var i = 0;
document.getElementById("homeImage").src = images[i];
setInterval(function () {
if (i == images.length) {
i = 0;
}
else {
document.getElementById("homeImage").src = images[i];
$(this).fadeIn("slow");
i++;
}
}, 3000);
});
I’m using ASP.NET MVC. Thanks!
3
Answers
You have to fade out before that, you can add
fadeOut
before changing the elememt’s background and then addfadeIn
when the background has changedThe steps will be
Working solution: