Javascript examples for jQuery Method and Property:slideToggle
The slideToggle() method toggles between slideUp() and slideDown() for the selected elements.
$(selector).slideToggle(speed,easing,callback);
Parameter | Require | Description | Value |
---|---|---|---|
speed | Optional. | speed of the slide 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. | A function to be executed after the slideToggle() method is completed | a function |
Possible easing values:
The following code shows how to Toggle between slideUp() and slideDown() for 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(){ $("button").click(function(){ $("p").slideToggle(); });/* w ww . j a va 2s. c om*/ }); </script> </head> <body> <p>This is a paragraph.</p> <button>Toggle slideUp() and slideDown()</button> </body> </html>