Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I make fadeOut blocking in JQuery?

Tags:

jquery

Pretty much as the question says, I have some code running on an interval:

$("#blah").fadeOut(2000);
$("#blah2").fadeIn(2000);

I'd like to fadeOut, then fadeIn, rather than have both going simultaneously. Is there an easy way?

like image 610
NibblyPig Avatar asked Jun 07 '10 12:06

NibblyPig


People also ask

How to set fadeOut time in jQuery?

The jQuery fadeOut() method is used to fade out a visible element. Syntax: $(selector). fadeOut(speed,callback);

How to stop fadeOut jQuery?

stop(). animate({opacity:'100'}) combo is what allows any fadIn/fadeOut to restart based on your trigger.

How does jQuery fadeOut work?

The . fadeOut() method animates the opacity of the matched elements. Once the opacity reaches 0, the display style property is set to none , so the element no longer affects the layout of the page. Durations are given in milliseconds; higher values indicate slower animations, not faster ones.


1 Answers

$("#blah").fadeOut(2000);
$("#blah2").delay(2000).fadeIn(2000);

Or:

$("#blah").fadeOut(2000, function(){
    $("#blah2").fadeIn(2000);
});
like image 110
James Avatar answered Nov 07 '22 11:11

James