jQuery fadeToggle()Method
Examples
Toggle between fading in and fading out for different boxes:
$("button").click(function(){
$("#div1").fadeToggle();
});
$("#div1").fadeToggle();
});
Try it Yourself »
Definition and Usage
The fadeToggle() methodfadeIn()andfadeOut()toggles between methods.
If the elements are faded out (hidden), fadeToggle() displays them with a fade-in effect.
If the elements are faded in (visible), fadeToggle() hides them with a fade-out effect.
Note:Hidden elements will not be fully displayed (they no longer affect the page layout).
Syntax
$(selector).fadeToggle(speed,easing,callback)
| Parameter | Description |
|---|---|
| speed | Optional. Specifies the speed of the fading effect. Possible values:
|
| easing | Optional. Specifies the speed of the element at different points of the animation. Default value is "swing". Possible values:
|
| callback | Optional. A function to be executed after the fadeToggle() method is completed. To learn more about callback, please visit ourjQuery Callbackthis chapter. |
More Examples
fadeToggle() - using the speed parameter
How to use the speed parameter to specify the speed of the fading effect.
fadeToggle() - using the callback parameter
How to use the callback parameter to execute a function after the fadeToggle() method is completed.
Other Extensions
jQuery Effects Methods