I’m trying to build this effect where divs fade in and out continuously. Where it gets tricky is that I need those fadeIn and fadeOut effects to stop on hover.
Right now, this code that I have doesn’t stop all fading quickly. What I need is an override? Is that even possible?
function animate() {
$("#bill-items-one").fadeIn(3000);
one = setInterval(function(){
$("#bill-items-one").fadeOut(3000);
$("#bill-items-one").fadeIn(3000);
}, 6000)
two = setInterval(function(){
$("#bill-items-two").fadeIn(3000);
$("#bill-items-two").fadeOut(3500);
}, 6500)
three = setInterval(function(){
$("#bill-items-three").fadeIn(2000);
$("#bill-items-three").fadeOut(4000);
}, 6000)
four = setInterval(function(){
$("#bill-items-four").fadeIn(3500);
$("#bill-items-four").fadeOut(3000);
}, 6500)
}
animate();
$(".bill-area").hover(
function(){
clearInterval(one);
clearInterval(two);
clearInterval(three);
clearInterval(four);
$(".bill-item").fadeOut("fast");
},
function(){
animate();
}
);
See also this link: http://jsfiddle.net/bKKE6/
http://api.jquery.com/stop/