jQuery slideToggle()Methods
Examples
Toggle between slideUp() and slideDown() on all <p> elements:
$("button").click(function(){
$("p").slideToggle();
});
$("p").slideToggle();
});
Try it Yourself »
Definition and Usage
The slideToggle() method performs on the selected elementsslideUp()andslideDown()the toggle between.
This method checks the visible state of the selected elements. If an element is hidden, slideDown() is run; if an element is visible, slideUp() is run - this creates a toggle effect.
Syntax
$(selector).slideToggle(speed,easing,callback)
| Parameters | Description |
|---|---|
| speed | Optional. Specifies the speed of the sliding effect. Possible values:
|
| easing | Optional. Specifies the speed of the element at different points in the animation. Default value is "swing". Possible values:
|
| callback | Optional. A function to execute after the slideToggle() method has finished executing. To learn more about callback, please visit ourjQuery Callbackthis chapter. |
More Examples
slideToggle() - Use the speed parameter
How to use the speed parameter to specify the speed of the sliding effect.
slideToggle() - Use the callback parameter
How to use the callback parameter to toggle between slideUp() and slideDown().
Other Extensions
jQuery Effects Methods