jQuery slideUp()
jQuery slideUp() can be applied on HTML element to generate a sliding up effect. Usually, the initial state of the HTML element is visible, so that when slideUp effect is applied, the HTML slides up and disappears.
In this tutorial, you will learn about jQuery slideUp() method, its syntax and usage, with examples.
Syntax – jQuery slideUp()
Following is the syntax to use jQuery slideUp() function
1. jQuery slideUp – Default
To slide up a selected HTML Element with default timing,
$("htmlElement").slideUp();
2. jQuery slideUp – slow/fast
You can also provide a “slow” or “fast” argument to the slideUp() method to make the sliding effect slow or fast respectively.
$("htmlElement").slideUp("slow"); $("htmlElement").slideUp("fast");
3. jQuery slideUp – Time in milliseconds
To control the sliding speed precisely, you can provide time in milliseconds as the argument to jQuery slideUp() method.
$("htmlElement").slideUp(4000); // for 4000 milliseconds
4. jQuery slideUp – Callback Function
You can also provide an optional callback function as second argument to slideUp(), to execute when the sliding effect is completed on the HTML element.
$("htmlElement").slideUp(4000, function(){ alert("Sliding is completed.") });
Examples – jQuery slideUp()
The following examples help you understand the usage of jQuery slideUp() method.
1. Example – Basic jQuery slideUp()
Following is a simple example to show the usage of jQuery slideUp() function.