Javascript examples for jQuery Method and Property:fadeOut
The fadeOut() method changes the opacity from visible to hidden.
$(selector).fadeOut(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 animation. | Default value is "swing" |
callback | Optional. | function to call after the fadeOut() method is completed | a function |
Possible easing values:
The following code shows how to Fade out all <p> elements:
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script> $(document).ready(function(){ $(".btn1").click(function(){ $("p").fadeOut() });//w w w. j av a2 s .c o m $(".btn2").click(function(){ $("p").fadeIn(); }); }); </script> </head> <body> <p>This is a paragraph.</p> <button class="btn1">Fade out</button> <button class="btn2">Fade in</button> </body> </html>