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:

fadeIn() Method

Here, the jQuery fadeIn() method is to fade in hidden elements.

Syntax for fadeIn()

Example: 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.

fadeOut() Method

The jQuery fadeOut() method can be used to fade out visible elements.

Syntax for fadeOut()
Example: fadeIn()





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()

fadeToggle() Example






fadeTo() Method

The method allows fading to a given opacity, value between 0 and 1.

Syntax for fadeTo()

Example for fadeTo()


$(“#div1”).fadeTo(“slow”, 0.15);

$(“#div2”).fadeTo(“slow”, 0.4);

$(“#div3”).fadeTo(“slow”, 0.7);


Leave a Reply

Your email address will not be published. Required fields are marked *