Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run jQuery fadeIn() and slideDown() simultaneously?

Tags:

jquery

I've got a div with display: none; Now I want to show it using both: fadeIn and slideDown simultaneously.

$(this).slideDown({duration: 'slow', queue: false}); $(this).fadeIn({duration: 'slow', queue: false}); 

The div is selected properly. But when I trigger the effect, all it does is the slideDown. And if I just delete the slideDown I can see the fadeIn, so there is nothing wrong with the syntax. But why doesn't it trigger both animations?

like image 232
iWebaholic Avatar asked Apr 02 '11 17:04

iWebaholic


People also ask

What is the syntax of jQuery fadeIn () method?

The jQuery fadeIn() method is used to fade in a hidden element. Syntax: $(selector). fadeIn(speed,callback);

What is fadeIn and fadeOut in jQuery?

jQuery has 2 fading methods which are . fadeIn() and . fadeOut(). The fadeIn method displays the element by fading it to opaque. The fadeOut method hides the element by fading it to transparent.

What is the difference between fadeOut and hide in jQuery?

fadeOut() the place will be removed at once. . show(duration) and . hide(duration) animate the size of element (also the opacity) to 100% and 0% and the place of elements is also animated in that duration.

Which are the jQuery fading methods?

jQuery example: fadeIn(), fadeOut(), and fadeToggle() This is an example using jQuery's fadeIn() , fadeOut() , and fadeToggle() methods to change the visibility of elements on the page with a fading effect.


1 Answers

Use animate() instead of fadeIn():

$(this)   .css('opacity', 0)   .slideDown('slow')   .animate(     { opacity: 1 },     { queue: false, duration: 'slow' }   ); 
like image 137
bpierre Avatar answered Sep 21 '22 00:09

bpierre