Introduction to jQuery
JQuery Syntax
JQuery Effects
JQuery HTML
JQuery Traversing
jQuery Sliding Effects — they’re perfect for making your UI feel smooth and interactive.
jQuery provides three main sliding methods to show and hide elements with a sliding motion:
|
Method |
Description |
|---|---|
|
.slideDown() |
Slides an element down to show it |
|
.slideUp() |
Slides an element up to hide it |
|
.slideToggle() |
Toggles between |
slideDown() MethodjQuery slideDown() method — it's a simple yet powerful way to reveal hidden content with a smooth sliding animation.
$(selector).slideDown(speed, easing, callback);
speed (optional) – "slow", "fast", or milliseconds (e.g., 1000)easing (optional) – "swing" (default) or "linear"callback (optional) – Function to run after the animation completesThe following example demonstrates the slideDown() method:
Try it yourself
slideUp() MethodThe .slideUp() method hides a visible element by sliding it up vertically.
$(selector).slideUp(speed, easing, callback);
speed (optional) – "slow", "fast", or milliseconds (e.g., 1000)easing (optional) – "swing" or "linear" (controls animation style)callback (optional) – Function to run after the animation completesThe following example demonstrates the slideUp() method:
Try it yourself
The .slideToggle() method checks if the element is visible:
.slideUp().slideDown()It’s like a switch for sliding visibility!
$(selector).slideToggle(speed, easing, callback);
speed (optional) – "slow", "fast", or milliseconds (e.g., 800)easing (optional) – "swing" or "linear" (controls animation style)callback (optional) – Function to run after the animation completesThe following example demonstrates the slideToggle() method:
Try it yourself