Table of Contents
You can fade elements in and out of visibility in jQuery using jQuery fading methods. This fading methods will gradually adjust the opacity of elements. Therefore, in this section we are going to see how to use fade elements using jQuery.
Just like other jQuery effects method, you can additionally specify the duration parmeter for fading methods to control the animation. And that duration parameter can be specified either using string (slow or fast) or in a number of milliseconds.
jQuery has the below fade methods, let’s see one by one:
Here, the jQuery fadeIn() method is to fade in hidden elements.
Syntax for fadeIn()
The above example shows how fadeIn() works with different parameters.The optional callback parameter is a function that has to be executed once the fading completes.
The jQuery fadeOut() method can be used to fade out visible elements.
Syntax for fadeOut()
jQuery fadeToggle() Method
This method will toggles between the fadeIn() and fadeOut() methods. Suppose, the elements are faded out, fadeToggle() method will fade it in and viceversa.
Syntax for fadeToggle()
The method allows fading to a given opacity, value between 0 and 1.