Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JQuery fadeIn vs show method difference

Tags:

jquery

Is there any real different between JQuery fadeIn() and show() methods implementation wise? of course other than the fact that fadeIn has that animation thing going on. I'm asking this question because I'm seeing a weird behavior.

I have some backbone views in which I'm creating an image tag and loading them. When I want to show them, they work on fadeIn() but not on show(). So is it the problem with my code or the way JQuery implements it.

like image 455
sublime Avatar asked Apr 15 '13 22:04

sublime


1 Answers

Calling show without passing any arguments is equivalent to calling .css('display', 'block'). If your opacity is set to 0 you still won't see the element.

However, according to the documentation:

When a duration, a plain object, or a "complete" function is provided, .show() becomes an animation method. The .show() method animates the width, height, and opacity of the matched elements simultaneously.

So, if you want .show to behave like .fadeIn, you'll need to pass a parameter to it.

like image 79
Stephen Avatar answered Oct 14 '22 08:10

Stephen