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

jQuery Effects – Sliding

jQuery Effects - Sliding


jQuery sliding methods can make elements slide up and down.

Click here to hide/show the panel

An inch of time is worth an inch of gold, so we provide you with quick and easy-to-understand learning content.

Here, you can obtain any knowledge you need in an easy-to-understand and convenient way.


Example

jQuery slideDown()
Demonstrates the jQuery slideDown() method.

jQuery slideUp()
Demonstrates the jQuery slideUp() method.

jQuery slideToggle()
Demonstrates the jQuery slideToggle() method.


jQuery Sliding Methods

With jQuery, you can create sliding effects on elements.

jQuery has the following sliding methods:


jQuery slideDown() method

The jQuery slideDown() method is used to slide an element down.

Syntax:

$(

selector

).slideDown(

speed,callback

);

The optional speed parameter specifies the duration of the effect. It can take the values "slow", "fast" or milliseconds.

The optional callback parameter is the name of the function to be executed after the sliding is complete.

The following example demonstrates the slideDown() method:

Example

$

(

"

#flip

"

)

.

click

(

function

(

)

{

$

(

"

#panel

"

)

.

slideDown

(

)

;

}

)

;

Try it »


jQuery slideUp() method

The jQuery slideUp() method is used to slide an element up.

Syntax:

$(

selector

).slideUp(

speed,callback

);

The optional speed parameter specifies the duration of the effect. It can take the values "slow", "fast" or milliseconds.

The optional callback parameter is the name of the function to be executed after the sliding is complete.

The following example demonstrates the slideUp() method:

Example

$

(

"

#flip

"

)

.

click

(

function

(

)

{

$

(

"

#panel

"

)

.

slideUp

(

)

;

}

)

;

Try it »


jQuery slideToggle() method

The jQuery slideToggle() method can toggle between the slideDown() and slideUp() methods.

If the elements are sliding down, slideToggle() will slide them up.

If the elements are sliding up, slideToggle() will slide them down.

$(

selector

).slideToggle(

speed,callback

);

The optional speed parameter specifies the duration of the effect. It can take the values "slow", "fast" or milliseconds.

The optional callback parameter is the name of the function to be executed after the sliding is complete.

The following example demonstrates the slideToggle() method:

Example

$

(

"

#flip

"

)

.

click

(

function

(

)

{

$

(

"

#panel

"

)

.

slideToggle

(

)

;

}

)

;

Try it »