Javascript examples for jQuery Method and Property:fadeToggle
The fadeToggle() method toggles between the fadeIn() and fadeOut() methods.
$(selector).fadeToggle(speed,easing,callback);
Parameter | Require | Description | Value |
---|---|---|---|
speed | Optional. | speed of the fading effect. | Default value is 400 milliseconds Possible values: milliseconds "slow" "fast" |
easing | Optional. | speed of the element in different points of the effect. | Default value is "swing" |
callback | Optional. | A function to be executed after the fadeToggle() method is completed | a function |
Possible easing values:
The following code shows how to Toggle between fading in and fading out different boxes:
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script> $(document).ready(function(){ $("button").click(function(){ $("p").fadeToggle("slow", function(){ console.log("The fadeToggle effect is finished!"); });// w w w . ja v a2 s .c o m }); }); </script> </head> <body> <button>Click me</button> <p>This is a paragraph.</p> </body> </html>