Example
Switch between showing and hiding the
element by using the sliding effect:
$(".btn1").click(function(){
$("p").slideToggle();
});
Definition and Usage slideToggle() method switches the visible state of an element by using a sliding effect (height change).
Hide the selected elements if they are visible, and show them if the selected elements are hidden.
Syntax
$(selector).slideToggle(speed,callback) Parameter Description
speed Optional. Specifies how quickly an element goes from hidden to visible (or vice versa). Default is "normal".
Possible values:
milliseconds (e.g. 1500)
"slow"
"normal"
"fast"
In case of setting speed, element During the switching process, it will gradually change its height (this will create a sliding effect).
callback optional. The function to be executed after the toggle function is executed.
To learn more about callbacks, visit our jQuery Callback chapter.
This parameter cannot be set unless the speed parameter is set.
Tips and Notes
Tip: If the element is already hidden, the effect will not produce any change unless a callback function is specified.