jQuery fadeOut()

jQuery fadeOut() can be applied on a visible HTML element to generate a fade out effect. When fade out effect is applied, the display attribute of element is changed to hidden. The transition though happens as a fade out.

Syntax – jQuery fadeOut()

Following is the syntax to use jQuery fadeOut() method

ADVERTISEMENT

1. jQuery fadeOut – Default

To fade out a selected HTML Element with default timing,

$("htmlElement").fadeOut();

2. jQuery fadeOut – slow/fast

You can also provide a “slow” or “fast” argument to the fadeOut() method to make the fade out process slow or fast respectively.

$("htmlElement").fadeOut("slow");
$("htmlElement").fadeOut("fast");

3. jQuery fadeOut – Time in milliseconds

To control the timing precisely, you can provide time in milliseconds as the argument to jQuery fadeOut() method

$("htmlElement").fadeOut(4000); // for 4000 milliseconds

Examples – jQuery fadeOut()

The following examples help you understand the usage of jQuery fadeOut() method :

1. Example – Basic jQuery fadeOut()

Following is a basic examples that demonstrates the usage of fadeOut() method.

2. Example – jQuery fadeOut(“slow”), fadeOut(“fast”)

You can provide one of the two options : “slow” or “fast” to control the speed of the effect.

3. Example – jQuery fadeOut(time_in_milliseconds)

Precise control of the fading speed can be done at the scale of milliseconds. Provide a value in milliseconds as first argument.

4. Example – jQuery fadeOut() with Callback function

Callback function can be provided an optional second argument. The callback function is called when the fading out effect is completed. In the following example, we have provided a callback function with alert statement inside the body. You can provide your own statements inside the callback function.

Conclusion

In this jQuery Tutorial, we have learnt jQuery fadeOut() method : Syntax and Usage with examples.