jQuery sliding effect example

  40 views   1 month ago jQuery

In this article, we will describe on sliding effects. There are three slide effects available in jQuery. So let's start from slideDown() method.

jQuery slideDown() method

jQuery slideDown() method is used to show hidden element in down slidding effect.

Syntax:

$(selector).slideDown(duration, callback);

Parameters:

duration is string 'slow', 'fast' or milliseconds

callback is a optional function which executes after the slideDown effect completes.

Example:

$('.normal').slideDown();
$('#slow').slideDown('slow');
$('div').slideDown(1000, function() {
    alert('slideDown effect completed.');
});

jQuery slideUp() method

jQuery slideUp() method is used to hide element in up slidding effect.

Syntax:

$(selector).slideUp(duration, callback);

Parameters:

duration is string 'slow', 'fast' or milliseconds

callback is a optional function which executes after the slideUp effect completes.

Example:

$('.normal').slideUp();
$('#slow').slideUp('slow');
$('div').slideUp(1000, function() {
    alert('slideUp effect completed.');
});

jQuery slideToggle() method

jQuery slideToggle() method hides and shows element in slidding effect. If the element is hidden, it will create slideDown effect else it will create slideUp effect.

Syntax:

$(selector).slideToggle(duration, callback);

Parameters:

duration is string 'slow', 'fast' or milliseconds

callback is a optional function which executes after the slideToggle effect completes.

Example:

$('.normal').slideToggle();
$('#slow').slideToggle('slow');
$('div').slideToggle(1000, function() {
    alert('slideToggle effect completed.');
});

I hope it will help you.

Author : Harsukh Makwana
Harsukh Makwana

Hi, My name is Harsukh Makwana. i have been work with many programming language like php, python, javascript, node, react, anguler, etc.. since last 5 year. if you have any issue or want me hire then contact me on [email protected]