jQuery fadeToggle() Method
The fadeToggle() Method in jQuery toggles between the fadeIn() and fadeOut() methods. If elements are faded in, fadeToggle() will fade out. If elements are faded out, fadeToggle() will fade in.
$(selector).fadeToggle(speed, easing, callback)
Parameters: This method accepts three parameters as mentioned above and described below:
- Speed: It is an optional parameter and used to specify the speed of the fading effect. The default value of speed is 400 millisecond. The possible value of speed are:
- easing: It is an optional parameter and used to specify the speed of element to different points of animation. The default value of easing is “swing”. The possible value of easing are:
- callback: It is optional parameter. The callback function is executed after fadeToggle() method is completed.
Below examples illustrate the fadeToggle() method in jQuery:
Example 1: This example display the fadeToggle() method effect in given speed. The speed can be set in terms of milliseconds.
Example 2: This example display the fadeToggle() method effect with swing easing. The easing is used to set the speed of element in different points of the animation.