jQuery slideUp(), slideDown() and slideToggle()

The jQuery slide methods slides elements up and down. jQuery comes with three handy methods to create the sliding effect easily :

jQuery slideUp() Method

The jQuery slideUp() method is used to slide up/hide an element.
Syntax:

Both are optional parameter.
Speed : parameter specifies the duration of the effect (“slow”, “fast”, or milliseconds (default:400)).
Callback : function to be executed after the sliding completes.

jQuery slideDown() Method

The jQuery slideDown() method is used to slide down/display an element with sliding effect.

Syntax:

Speed: specifies the duration of the effect(“slow”, “fast”, or milliseconds(default:400))
callback: function to be executed after the sliding completes.


jQuery slideToggle() Method

If the matched element is displayed, it will hide with a slide up effect; if hidden, it will display with a slide down effect.

Syntax:

Speed: specifies the duration of the effect(“slow”, “fast”, or milliseconds(default:400))
callback: function to be executed after the sliding completes.

Examples :

We will cause .slideToggle()/.slideUp()/.slideDown() to be called when another element is clicked:

If the Book Panel is displaying then on click of “clickme”, we can call slideUp method for hiding the panel.

If we want to display Book Panel on click of “clickme”, we can call slideDown method.

All these three jQuery slideUp(), slideDown() and slideToggle() methods are very important to display/hide panel with sliding effects.

You Might Interested In

Leave a Reply

Enclose a code block like: <pre><code>Your Code Snippet</code></pre>.