jQuery .slideUp() Method

Beginner
6 min read
Updated: Oct 2026
5 examples
Live preview

What Is .slideUp()?

.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.

Remember
$("#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
NeedUse
Vertical collapse hide$el.slideUp()
Vertical expand.slideDown()
Toggle slide direction.slideToggle()
Opacity hide.fadeOut()
Instant hide.hide()

How to Use .slideUp()

Start with a visible element, then call .slideUp() from a click (or other) handler.

  1. Select a visible target ($("#panel")).
  2. On a user action, call .slideUp() (optional duration / easing / complete).
  3. jQuery animates height from natural size down to 0.
  4. When finished, display: none removes the element from layout.
  5. Optional complete runs once per matched element when done.
PieceRequired?Role
Matched setYesElements to collapse (should be visible)
durationNoDefault 400; also "fast" / "slow"
easingNoSince 1.4.3 — swing (default) or linear
completeNoOnce per element when its slide ends
Return value—jQuery object (chainable)

Pseudocode

Pseudocode
call $(elements).slideUp(duration?, easing?, complete?)

for each matched element:
    if already hidden:
        little or no change
    else:
        animate height from natural height → 0
        set display: none
        content below slides up

    if complete was provided:
        call complete once for this element
        (this = the DOM element)

return the jQuery set for chaining

Cheat Sheet

Keep these two facts handy while building slide collapses.

TopicDetail
Syntax.slideUp([duration] [, easing] [, complete])
Options form.slideUp({ duration, easing, complete, … })
SincejQuery 1.0 (easing arg since 1.4.3)
Default duration400 ms
Presets"fast" = 200 · "slow" = 600
Easingswing (default) · linear
End statedisplay: none when height reaches 0
Related.slideDown() · .slideToggle()

Live Preview

Run slideUp on the sample panel. Use Reset to show it again.

This panel slides up and hides. Reset restores it.

Run a slideUp, then Reset to show the panel again for another try.

Result
Ready — click Run to slideUp.

jQuery Examples

Short, copy-ready snippets. Open DevTools, or use Try It Yourself for a live editor.

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.
  4. Hide. Then display: none; callback runs once.

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).
  4. Note. For animated both ways, prefer .slideToggle().

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).
  4. Message. Reads the button text inside that parent.

Example 4 — Default Duration (400 ms)

Omit duration to use the default 400 ms collapse.

jQuery
$("#dismiss-btn").on("click", function () {
  $("#panel").slideUp();
});
Try It Yourself

How It Works

  1. No args. Default duration is 400 ms.
  2. Animate. Height shrinks to 0.
  3. Layout. display: none when finished.
  4. Use case. Simple dismiss / close without extras.

Example 5 — Linear Easing (Since 1.4.3)

Three-argument form: duration, easing, complete.

jQuery
$("#close").on("click", function () {
  $("#drawer").slideUp(600, "linear", function () {
    $(this).text("Slide complete at constant speed");
  });
});
Try It Yourself

How It Works

  1. Duration. 600 ms total.
  2. Easing. "linear" keeps a constant rate.
  3. Collapse. Height goes to 0, then display: none.
  4. Complete. Updates text when the tween ends.

Edge Cases & Pitfalls

Watch these when collapses feel wrong or “do nothing.”

hidden

Already hidden → little effect

Call .slideUp() on visible elements. Hidden ones are already collapsed.

callback

Complete runs once per element

Collapsing three panels fires the callback three times. Use .promise().done() for one “all finished” hook.

display

Ends at display: none

After height hits 0, the element leaves the layout — that is intended.

queue

Rapid clicks queue animations

Use .stop(true, true) before .slideUp() on busy dismiss buttons.

fx.off

jQuery.fx.off skips the tween

When true, collapses snap shut instantly (duration 0).

Browser Support

.slideUp() has been part of jQuery since 1.0 (positional easing since 1.4.3). It works in every browser that runs your loaded jQuery version — no separate browser feature flag.

✓ Stable · jQuery 1.0+

jQuery .slideUp()

Supported across jQuery 1.x, 2.x, and 3.x. Prefer a current jQuery 3.x build. Height animation uses jQuery’s fx engine.

100% With jQuery
Google Chrome All versions · Desktop & Mobile
Full support
Mozilla Firefox All versions · Desktop & Mobile
Full support
Apple Safari All versions · macOS & iOS
Full support
Microsoft Edge All versions · Chromium & Legacy
Full support
Internet Explorer IE 6+ · Legacy environments
Full support
Opera All modern versions
Full support
.slideUp() Universal

Bottom line: Safe for dismissals, alerts, and panels. Guard rapid clicks with .stop(true, true), and respect jQuery.fx.off for reduced motion.

Performance Notes

ApproachCostBest for
One panel slideUpCheapAlerts, banners, dismiss boxes
Many elements at onceMore layout workPrefer one wrapper when possible
Queued spam clicksWasted framesAlways .stop(true, true) on dismiss

Height collapses trigger layout. One container is cheaper than sliding dozens of siblings — and stopping before collapse avoids stacked hide queues.

Key Takeaways

  • Role: animated hide via height → display: none — since jQuery 1.0.
  • Call: $el.slideUp() — default 400 ms; optional easing + complete.
  • Pair: .slideDown() to reopen; .slideToggle() for both directions.
  • Guard: element must be visible; stop queues on busy buttons.

One line: .slideUp() collapses a visible element by animating height to 0, then sets display: none.

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() tutorial →

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