jQuery .slideUp() Method

Beginner
⏱️ 9 min read
📚 Updated: Jul 2026
🎯 5 Examples
🚀 5 Try-it labs
Height Collapse

What You’ll Learn

The .slideUp() instance method hides matched elements with a sliding motion by animating height. This tutorial covers all three overloads since jQuery 1.0 (including easing since 1.4.3), default and preset durations, per-element callbacks, comparisons with .slideDown(), .hide(), .fadeOut(), and .slideToggle(), and five hands-on examples from the official jQuery API.

01

Collapse

Full height → hidden

02

Duration

ms, fast, slow

03

Three overloads

Positional / options

04

Easing

Since 1.4.3

05

Callbacks

Once per element

06

fx queue

Chain with slideDown

Introduction

Instant .hide() removes content in one frame. When you want a vertical collapse — an accordion panel, dismissible alert, or menu sliding shut — .slideUp() is the shorthand jQuery effect for that job.

Available since jQuery 1.0, .slideUp() animates the height of matched elements so lower page content slides up to conceal them. It enqueues on the default fx queue like other effects, which means you can chain it after .show(), .delay(), or another animation for readable sequential dismissals.

Understanding the .slideUp() Method

Per the official jQuery API, .slideUp() hides the matched elements with a sliding motion. The method animates height from full size to zero, causing content below to shift upward as the collapse progresses. Once height reaches 0 (or the CSS min-height value), display is set to none.

Elements should start visible — taking up layout space in the document. jQuery tweens height over the duration you supply, then leaves the element fully hidden with display: none so it no longer affects page layout.

💡
Beginner Tip

Think of .slideUp() as the vertical exit to .slideDown()’s reveal. Show first, slide up when ready to dismiss — one line replaces manual height and display juggling.

📝 Syntax

Three overloads of .slideUp:

jQuery
// 1) Duration and complete callback
jQuery( selector ).slideUp( [duration ] [, complete ] )
// 2) Options object — queue, step, Promise callbacks
jQuery( selector ).slideUp( options )
// 3) Duration, easing, complete — since jQuery 1.4.3
jQuery( selector ).slideUp( [duration ] [, easing ] [, complete ] )

Parameters

  • duration (Number or String, default 400) — milliseconds, or "fast" (200) / "slow" (600).
  • easing (String, default "swing", since 1.4.3) — built-in swing or linear; plugins add more.
  • complete (Function) — called once per matched element when that element’s slide finishes.
  • options.queue (Boolean or String, default true) — false runs immediately; string names a custom queue.
  • options.step, progress, start, done, fail, always — same Promise-style hooks as other effects (since 1.8).

Return value

  • A jQuery object for chaining further queued methods on the same set.

Official jQuery API description

jQuery
// With the element initially shown, hide it slowly:
$( "#clickme" ).on( "click", function() {
  $( "#book" ).slideUp( "slow", function() {
    // Animation complete.
  });
});

⚡ Quick Reference

GoalCode
Default 400 ms collapse$el.slideUp()
Slow collapse (600 ms)$el.slideUp("slow")
Custom duration + callback$el.slideUp(800, function() { ... })
Linear easing since 1.4.3$el.slideUp(600, "linear", function() { ... })
Options overload$el.slideUp({ duration: 500, easing: "linear", complete: fn })
Reset then slide collapse$el.show().slideUp(800)

📋 .slideUp() vs slideDown vs hide vs fadeOut vs slideToggle

Five ways to change visibility — only .slideUp() collapses visible elements by animating height to zero then hiding in one shorthand call.

.slideUp()
$el.slideUp("slow")

Collapses visible elements and animates height to zero — lower content slides up to conceal items

.slideDown()
$el.slideDown("slow")

Opposite reveal — unhides and expands height open; pair with .slideUp() for accordion UX

.hide()
$el.hide()

Instant hide with no height transition — use when animation is not needed

.fadeOut()
$el.fadeOut("slow")

Opacity hide — no height animation; content below does not slide up to fill the gap

.slideToggle()
$el.slideToggle("slow")

Auto-picks slideDown or slideUp based on current visibility — one method for toggle panels

Examples Gallery

Each example demonstrates an official jQuery API .slideUp() pattern. Open DevTools or use the Try-it links. All five mirror live demos on api.jquery.com/slideUp/.

📚 Getting Started

Official jQuery API demos — basic click-to-hide and body-click toggle patterns.

Example 1 — Basic Usage: Visible #book slideUp("slow") on Click

With the element initially shown, click #clickme to slide up #book over the slow preset (600 ms).

jQuery
// With the element initially shown, we can hide it slowly:
$( "#clickme" ).on( "click", function() {
  $( "#book" ).slideUp( "slow", function() {
    // Animation complete.
  });
});
Try It Yourself

How It Works

.slideUp("slow") maps to 600 milliseconds. jQuery animates height from full size to zero, sets display: none when done, and fires the callback once per matched element.

Example 2 — Toggle All Divs show("slow") or slideUp() (Official Example 1)

Each body click checks whether the first div is hidden. If so, all divs show slowly; otherwise they slide up with the default 400 ms duration.

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

How It Works

:hidden on the first div decides direction. When visible, .slideUp() collapses every matched div in parallel; when hidden, .show("slow") reveals them with animation.

📈 Advanced Patterns

Parent collapse with callback, default duration, and easing since jQuery 1.4.3.

Example 3 — Button Parent slideUp("slow") with Callback (Official Example 2)

Click a button to slide up its parent paragraph slowly. In the callback, display a message with the button’s text.

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

How It Works

$(this).parent() targets the wrapping paragraph. The complete callback runs once per parent after its slide finishes. Inside, this refers to the parent DOM element — ideal for reading the clicked button’s text without extra variables.

Example 4 — Default slideUp() 400 ms on Visible Panel

Omit the duration argument to use the default 400 ms slide when the user clicks a button to dismiss a visible panel.

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

How It Works

When duration is omitted, jQuery uses 400 ms. This is the simplest collapse call — show the panel with CSS or .show(), then .slideUp() on click to dismiss.

Example 5 — slideUp(600, "linear", callback) with Easing Since 1.4.3

Use the three-argument overload to pick linear easing instead of the default swing curve, with a completion callback.

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

How It Works

Since jQuery 1.4.3, the middle argument names an easing function. Built-in options are swing (default, accelerates mid-animation) and linear (constant rate). jQuery UI adds more easing plugins.

🚀 Common Use Cases

  • Accordion and FAQ panels — slide up answers on second header click to collapse open sections.
  • Dismissible alerts — hide notification banners with a vertical slide instead of instant removal.
  • Progressive disclosure — toggle all visible divs closed or open, as in the official body-click demo.
  • Form section cleanup — slide up completed form steps and update status text in the complete callback.
  • Notification drawers — chain .show().slideUp() for repeatable alert-style dismissals.
  • Effect chains — combine with .delay() and .slideDown() for full expand/collapse choreography on the fx queue.

🧠 How .slideUp() Collapses an Element

1

Element starts visible

Target must be visible — taking up layout space in the document. Already-hidden elements see little change.

Prerequisite
2

Height tween begins

jQuery captures the element’s current height, then begins animating it downward toward zero while content below starts sliding up.

Setup
3

Height animates over duration

Default 400 ms, or your chosen ms / fast / slow with optional swing or linear easing. Lower content slides up to fill the gap.

Tween
4

display:none and callback

Height reaches 0 (or min-height), then display: none is set. complete fires once per matched element; fx queue advances to the next step.

📝 Notes

  • Available since jQuery 1.0; easing overload added in 1.4.3; Promise callbacks in options since 1.8.
  • Default duration is 400 ms; "fast" = 200 ms, "slow" = 600 ms.
  • Animates height, not opacity — lower page content physically slides up to conceal the collapsing element.
  • Callbacks fire once per matched element — use .promise().done() for one set-level callback.
  • Elements should be visible first; calling on hidden content produces minimal visible effect.
  • Set jQuery.fx.off = true globally to disable all effects including .slideUp() (duration becomes 0).
  • IE note: if .slideUp() is called on a <ul> whose <li> children have position: relative, absolute, or fixed, the effect may fail in IE6–IE9 unless the ul has layout. Add position: relative; and zoom: 1; to the ul to fix it.

Browser Support

.slideUp() is a jQuery instance method since 1.0+. It uses jQuery’s internal fx engine and height tweens — behavior is consistent wherever jQuery runs, independent of CSS transition support.

Stable · jQuery 1.0+

jQuery .slideUp()

Supported in all jQuery 1.x, 2.x, 3.x, and 4.x releases. Works in Chrome, Firefox, Safari, Edge, IE 6+ (with compatible jQuery builds), and Node.js via jsdom.

100% jQuery slideUp API support
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: Learn .slideUp() alongside .slideDown(), .slideToggle(), and .finish() to build polished expand and collapse sequences in legacy and modern jQuery apps.

Conclusion

The .slideUp() method is jQuery’s shorthand for hiding visible elements with a vertical sliding motion. Three overloads cover simple durations, options objects, and easing since 1.4.3.

Keep elements visible before calling, pick your duration or preset, and use the complete callback to chain follow-up effects. Pair this method with .slideDown() behind you and .slideToggle() ahead to master full expand/collapse UX.

💡 Best Practices

✅ Do

  • Ensure elements are visible before calling .slideUp()
  • Use "slow" / "fast" for readable preset timing across your app
  • Chain .show().slideUp() to replay accordion-style dismissals on repeated clicks
  • Use the complete callback to update status text or remove DOM nodes without setTimeout
  • Call .promise().done() when you need one callback after all elements finish

❌ Don’t

  • Expect hidden elements to animate — .slideUp() is for visible content
  • Use .slideUp() when you need an opacity fade — choose .fadeOut() instead
  • Forget the IE ul/li layout fix when list items use positioned CSS
  • Assume one callback covers the whole set — it fires per matched element
  • Forget jQuery.fx.off in tests — it zeroes duration for all effects globally

Key Takeaways

Knowledge Unlocked

Five things to remember about .slideUp()

Shorthand hide by sliding visible elements closed with a height animation.

5
Core concepts
02

Three overloads

Positional / options

API
🔄 03

400 / fast / slow

Default durations

Timing
📝 04

Per-element cb

Not once per set

Callback
👁 05

Start visible

Layout space first

Rule

❓ Frequently Asked Questions

.slideUp() hides matched elements with a sliding motion by animating their height to zero. Lower page content slides up to conceal the collapsing items. When height reaches 0 (or min-height), display is set to none. Use it when you want a vertical collapse instead of an instant .hide().
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 hidden elements by animating height open. .hide() removes elements instantly with no transition. .fadeOut() animates opacity, not height. .slideToggle() picks slideDown or slideUp based on current visibility. .slideUp() collapses visible elements and sets display:none when done.
Duration is in milliseconds. Default is 400 ms when omitted. The strings "fast" (200 ms) and "slow" (600 ms) map to preset speeds, the same as other jQuery effect methods.
The complete callback runs once per matched element when that element's slide finishes — not once for the entire set. Use .promise().done() when you need a single callback after all elements complete.
Yes. .slideUp() is meant for elements that are visible and taking up layout space. Calling it on already-hidden elements has little visible effect because they are already collapsed and display:none.
Did you know?

The official jQuery .slideUp() button demo collapses each button’s parent paragraph with .slideUp("slow"), then reads the clicked button’s text inside the completion callback via $( "button", this ).text(). That pattern — parent-targeted collapse, per-element callback messaging — is one of the most copied sequencing tricks in the slide effects API, and it needs no setTimeout at all.

Continue to .slideToggle()

Display or hide elements with one call — jQuery picks slideDown or slideUp based on visibility.

.slideToggle() →

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.

6 people found this page helpful