Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you pause before fading an element out using jQuery?

I would like to flash a success message on my page.

I am using the jQuery fadeOut method to fade and then remove the element. I can increase the duration to make it last longer, however this looks strange.

What I would like to happen is have the element be displayed for five seconds, then fade quickly, and finally be removed.

How can you animate this using jQuery?

like image 822
Bjørn Avatar asked Sep 03 '08 18:09

Bjørn


People also ask

How do you fadeOut an element in jQuery?

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

Which are the jQuery fading methods?

Fading is the property that allows manipulating the opacity (transparency) of HTML elements. JQuery offers four fading methods that allow you to change the transparency of elements. These methods include, fadeIn(), fadeOut(), fadeToggle(), and fadeTo().

What is fadeIn and fadeOut in jQuery?

jQuery fadeIn() Method The fadeIn() method gradually changes the opacity, for selected elements, from hidden to visible (fading effect). Note: Hidden elements will not be displayed at all (no longer affects the layout of the page). Tip: This method is often used together with the fadeOut() method.

Which jQuery method can be used to gradually change the height of a selected element?

Definition and Usage. The animate() method performs a custom animation of a set of CSS properties. This method changes an element from one state to another with CSS styles. The CSS property value is changed gradually, to create an animated effect.


1 Answers

The new delay() function in jQuery 1.4 should do the trick.

$('#foo').fadeIn(200).delay(5000).fadeOut(200).remove(); 
like image 112
Nathan Long Avatar answered Sep 30 '22 19:09

Nathan Long