Instance
Toggle the <p> element between display and hidden states by using the slide effect:
Copy Code code as follows:
$ (". Btn1"). Click (function () {
$ ("P"). Slidetoggle ();
});
Definitions and usage
The Slidetoggle () method toggles the visible state of an element by using a sliding effect (height change).
If the selected element is visible, the elements are hidden, and if the selected element is hidden, the elements are displayed.
Grammar
$ (selector). Slidetoggle (speed,callback) parameter description
Speed Optional. Specify the speed (or vice versa) from which elements are hidden to visible. The default is "normal".
Possible values:
Milliseconds (for example, 1500)
"Slow"
"Normal"
"Fast"
In the case of setting the speed, the element will gradually change its height during the switching process (this will create a sliding effect).
Callback optional. The function to execute after the toggle function has finished executing.
For more information on callback, please visit our JQuery callback chapter.
This parameter cannot be set unless the speed parameter is set.
Tips and comments
Tip: If the element is already hidden, the effect does not change unless the callback function is specified.