What is the slideToggle method in jQuery?
In jQuery, the slideToggle() method is used to toggle an element by sliding it up or down, depending on the element’s current state.
If the element has been slid down, then the slideToggle() method slides it up to hide the contents.
If the element has been slid up, then the slideToggle() method slides it down to reveal the hidden content.
Syntax
$(selector).slideToggle(speed,easing,callback)
Parameters
selector: The element to be acted upon.speed: An optional parameter used to specify the duration of the event;speedcan be a value in milliseconds or either of “slow” and “fast”.easing: An optional parameter used to specify the speed of the element at different points of the animation.easingcan take values of “swing” or “linear”, with swing being the default value.callback: An optional parameter for the callback function that gets called once the sliding is over.
Code
In the code below, the text "Platform like no other!" gets toggled once the Toggle Slide button is clicked.