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.
$(selector).slideToggle(speed,easing,callback)
selector
: The element to be acted upon.speed
: An optional parameter used to specify the duration of the event; speed
can 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. easing
can 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.In the code below, the text "Platform like no other!"
gets toggled once the Toggle Slide
button is clicked.