Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

jQuery slideToggle() method

jQuery slideToggle() method

jQuery effects methods jQuery effects methods

Example

Toggle between slideUp() and slideDown() on all

elements:

$("button").click(function(){

$("p").slideToggle();

});

Try it »


Definition and Usage

The slideToggle() method toggles between slideUp() and slideDown() slideUp() and slideDown().

This method checks the visibility of the selected elements. If an element is hidden, slideDown() runs; if an element is visible, slideUp() runs - creating a toggling effect.

Syntax

$(

selector

).slideToggle(

speed,easing,callback

)

Parameters Description
speed Optional. Specifies the speed of the sliding effect.

Possible values:

  • Millisecond
  • "slow"
  • "fast"
  • | | *easing* | Optional. Specifies the speed of the element at different points in the animation. The default is "swing".

    Possible values:

    **Tip:** More easing functions are available in extension plugins. | | *callback* | Optional. A function to be executed after the slideToggle() method finishes.

    To learn more about callback, please visit our jQuery Callback chapter on callbacks.

    |

    More examples

    slideToggle() - Using the speed parameter
    How to use the speed parameter to specify the speed of the sliding effect.

    slideToggle() - Using the callback parameter
    How to use the callback parameter to toggle between slideUp() and slideDown().


    jQuery effects methods jQuery effects methods