I have 5 images which I want to fade in and out randomly and
independently from each other.
This is the code I have so far:
$('.main_nav img').each(function() {
$(this).css("opacity", 0);
animatedLink = this;
t = setTimeout("timedAnim(animatedLink)",getRandom());
});
function getRandom() {
return (Math.random()*1000)+600;
}
function timedAnim(obj) {
if(($(obj).css("opacity")) == 0){
$(obj).css("opacity", 1);
}
else{
$(obj).css("opacity", 0);
}
animatedLink = obj;
t = setTimeout("timedAnim(animatedLink)",getRandom());
}
But the only thing that happens is the last image blinking
continuously. I'm guessing that either there's something wrong with
using .each or I can't use the same variable (t) for each animation,
but I don't know how to do it differently.
Anyone care to help?