jQuery .slideUp() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
Effects

Definition

.slideUp() (since jQuery 1.0) hides matched elements with a sliding motion by animating height to 0. Lower content slides up as items collapse. When height reaches 0, display: none frees layout space. Returns the jQuery object for chaining.

Syntax

Start with these common calls. Keep them short and readable.

jQuery
$("#panel").slideUp();              // default 400 ms
$("#panel").slideUp("slow");        // 600 ms
$("#panel").slideUp(600, "linear", function () { /* done */ });

// Visible → height shrinks → display: none
// Content below slides up as height decreases
CallWhat it does
.slideUp()Learn jQuery .slideUp(): hide matched elements with a sliding height animation since 1.0, duration presets, easing since 1.4.3, per-element callbacks, and compare with slideDown, hide, fadeOut, and slideToggle.

Load jQuery before your script (CDN or local file), then wrap DOM work in $(function () { ... }) when needed.

Parameters

ParameterDescription
Step 1Select a visible target ($("#panel")).
Step 2On a user action, call .slideUp() (optional duration / easing / complete).
Step 3jQuery animates height from natural size down to 0.

Return Value

Return ValueDescription
Value / undefinedGetters usually return a value from the first matched element, or undefined when nothing applies.

jQuery Examples

Example 1 — Slow Collapse on Click

Official pattern: element starts shown; click slides it up over 600 ms.

jQuery
$("#clickme").on("click", function () {
  $("#book").slideUp("slow", function () {
    // Animation complete.
  });
});
Try It Yourself

How It Works

  1. Visible start. The target begins shown in the layout.
  2. Preset. "slow" means 600 ms.
  3. Tween. Height animates from natural size to 0.

Example 2 — slideUp or .show("slow") (Official Ex. 1)

If the first box is hidden, show all slowly; otherwise slide them up.

jQuery
$("#toggle").on("click", function () {
  if ($(".box").first().is(":hidden")) {
    $(".box").show("slow");
  } else {
    $(".box").slideUp();
  }
});
Try It Yourself

How It Works

  1. Check. :hidden on the first box picks the branch.
  2. Collapse. Visible → .slideUp() on all boxes.
  3. Reveal. Hidden → .show("slow") (not slideDown here).

Example 3 — Parent slideUp with Callback (Official Ex. 2)

Each button slides up its parent paragraph; the callback updates a message.

jQuery
$("button").on("click", function () {
  $(this).parent().slideUp("slow", function () {
    $("#msg").text($("button", this).text() + " has completed.");
  });
});
Try It Yourself

How It Works

  1. Parent. $(this).parent() is the wrapping paragraph.
  2. Slide. That p collapses with "slow".
  3. Callback. this is the finished p (still in the DOM).

Frequently Asked Questions

.slideUp() hides matched elements with a sliding motion by animating height to zero. Lower page content slides up as items collapse. When height reaches 0 (or min-height), display is set to none so the element no longer affects layout.
1) .slideUp([duration] [, complete]) — optional duration and completion callback. 2) .slideUp(options) — an options object with duration, easing, queue, step, progress, and Promise-style callbacks. 3) .slideUp([duration] [, easing] [, complete]) — positional easing since jQuery 1.4.3.
.slideDown() reveals by animating height open. .hide() removes instantly with no transition. .fadeOut() animates opacity, not height. .slideToggle() picks slideDown or slideUp from current visibility. .slideUp() only collapses and hides.
Milliseconds, or the strings "fast" (200 ms) and "slow" (600 ms). Default is 400 ms when omitted.
Once per matched element when that element’s slide finishes — not once for the whole set. Use .promise().done() when you need a single callback after every element completes.
Yes. Start with a visible element that takes up layout space. Calling .slideUp() on already-hidden elements has little visible effect.

Next: .slideToggle() Method

One call that slides open or closed from the element’s current visibility.

.slideToggle() Method tutorial →

CODETOFUN NEWS

Stay Ahead in Tech

Get the latest IT news, programming updates, and technology trends directly on your phone.

Your daily dose of tech, straight to your feed.

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

10 people found this page helpful