Instance
By using the slide effect, you can switch between the display and hide States <p> elements:
Copy codeThe Code is as follows:
$ (". Btn1"). click (function (){
$ ("P"). slideToggle ();
});
Definition and usage
The slideToggle () method uses the sliding effect (height change) to switch the visible state of the element.
If the selected elements are visible, these elements are hidden. If the selected elements are hidden, these elements are displayed.
Syntax
$ (Selector). slideToggle (speed, callback) parameter description
Speed is optional. Specifies the speed (or opposite) at which elements are hidden to be visible ). The default value is "normal ".
Possible values:
Millisecond (e.g. 1500)
"Slow"
"Normal"
"Fast"
When the speed is set, the height of an element changes gradually during the switching process (this will create a sliding effect ).
Callback is optional. The function to be executed after the toggle function is executed.
To learn more about callback, visit our jQuery Callback chapter.
This parameter cannot be set unless the speed parameter is set.
Tips and comments
Tip: If the element is hidden, the effect will not change unless the callback function is specified.