jQuery .hide() Method

Beginner
⏱️ 11 min read
📚 Updated: Jul 2026
🎯 5 Examples
🚀 5 Try-it labs
Visibility & effects

What You’ll Learn

The .hide() method hides matched elements instantly or with a smooth animation. This tutorial covers the no-argument form since jQuery 1.0, duration strings like "slow" and "fast", complete callbacks, how jQuery saves the original display value for .show(), comparisons with .css() and .toggle(), the official jQuery API demos, and five practical try-it examples.

01

Instant

No args

02

Animated

Duration

03

Callback

complete

04

vs .show()

Pair API

05

Saves display

Cache

06

Since 1.0

Core API

Introduction

Hiding content is one of the most common UI tasks in web development — closing menus, dismissing alerts, collapsing panels, and stepping through wizards. jQuery’s .hide() method hides every element in a matched set with a single line of code.

With no parameters, .hide() is the simplest approach: elements disappear immediately with no animation. Under the hood this is similar to .css( "display", "none" ), but jQuery also saves the element’s original display value so .show() can restore inline, block, flex, or whatever layout mode the element used before.

Pass a duration — a number in milliseconds or the strings "slow" (600 ms) or "fast" (200 ms) — and .hide() becomes an animation that shrinks width, height, and opacity together before setting display: none. Browse the jQuery DOM hub for related manipulation methods.

Understanding the .hide() Method

.hide( [duration ] [, complete ] ) operates on a jQuery collection. Each matched element is hidden; the method returns the same collection for chaining. Hidden elements remain in the DOM — they simply stop affecting page layout.

When animation is involved, jQuery fires a complete callback once per matched element after that element’s animation finishes. Inside the callback, this refers to the DOM element being animated. This is useful for removing nodes with .remove() only after the fade-out completes.

💡
Beginner Tip

The official jQuery demo calls $( "p" ).hide() on page load to hide every paragraph instantly, then binds a click handler on a link that hides itself with $( this ).hide(). No animation — just immediate visibility changes.

📝 Syntax

jQuery .hide() supports several forms:

Instant hide — since 1.0

jQuery
.hide()
  • No arguments — hides immediately with no animation.
  • Saves the current display value for later .show() restoration.

Animated hide with duration

jQuery
.hide( duration [, complete ] )

// Milliseconds (default animation length is 400 when duration provided)
.hide( 600 )

// Named speeds
.hide( "slow" )   // 600 ms
.hide( "fast" )   // 200 ms

Options object — since 1.0

jQuery
.hide( {
  duration: 400,
  easing: "swing",
  complete: function() {
    // Called once per matched element when its animation finishes
  }
} )

Easing form — since 1.4.3

jQuery
.hide( duration [, easing ] [, complete ] )

.hide( 600, "linear", function() {
  console.log( "Hidden!" );
} );

⚡ Quick Reference

GoalCode
Hide instantly$("#panel").hide()
Hide slowly (600 ms)$("#panel").hide("slow")
Hide quickly (200 ms)$("#panel").hide("fast")
Custom duration$("#panel").hide(400)
Run code after hide$("#panel").hide(500, fn)
Show again later$("#panel").show()

📋 .hide() vs .show() vs .toggle() vs .css()

Four ways to change visibility — know which one fits your UI.

.hide()
invisible

Set display none — saves original display for .show() — optional animation

.show()
visible

Reverse of .hide() — restores saved display value with optional animation

.toggle()
flip

Show hidden elements, hide visible ones — one method for on/off UIs

.css('display')
raw CSS

Direct style change — no saved display, no built-in animation

Examples Gallery

Example 1 covers instant hiding. Examples 2–5 follow the official jQuery API documentation — hide paragraphs on load, animate with "slow", fade an image with a callback, and remove divs after a timed hide. Use DevTools or the Try-it links to run each snippet in the browser.

📚 Getting Started

Instant hide and the official jQuery paragraph demo.

Example 1 — Instant Hide (No Animation)

The simplest form — hide matched elements immediately with no duration argument.

jQuery
$( ".target" ).hide();

// Equivalent effect to .css( "display", "none" )
// but jQuery saves the original display value for .show()
Try It Yourself

How It Works

With zero arguments, jQuery sets display: none on each matched element right away. The previous display value is cached internally so a later .show() can bring the element back with the correct layout mode.

Example 2 — Official Demo: Hide Paragraphs on Load

Hide all paragraphs when the page loads; clicking a link hides the link itself.

jQuery
$( "p" ).hide();

$( "a" ).on( "click", function( event ) {
  event.preventDefault();
  $( this ).hide();
} );
Try It Yourself

How It Works

The selector $( "p" ) matches every paragraph. Calling .hide() on page load removes them from layout immediately. The click handler uses $( this ) to hide only the clicked anchor.

📈 Animation & Callbacks

Slow fades, completion handlers, and post-hide cleanup.

Example 3 — Animated Hide with "slow"

Hide visible paragraphs over 600 milliseconds when a button is clicked.

jQuery
$( "button" ).on( "click", function() {
  $( "p" ).hide( "slow" );
} );

// "slow"  → 600 ms
// "fast"  → 200 ms
// 400     → 400 ms (default when duration is a number)
Try It Yourself

How It Works

When a duration is provided, .hide() becomes an animation method. jQuery animates dimensions and opacity in parallel, then sets display: none so the hidden elements no longer affect layout.

Example 4 — Hide with Complete Callback

Hide an image slowly and run a function when the animation finishes — official book demo pattern.

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

How It Works

The second argument to .hide() is a callback fired after each element’s animation completes. Inside the function, this is the DOM element. Use it to show messages, load content, or trigger the next animation in a sequence.

Example 5 — Hide Then Remove from DOM

Click a div to hide it over 2 seconds, then remove it when the animation completes.

jQuery
$( "div" ).on( "click", function() {
  $( this ).hide( 2000, function() {
    $( this ).remove();
  } );
} );
Try It Yourself

How It Works

.hide() alone keeps elements in the document. Combining it with .remove() in the callback gives users a smooth exit animation before the node is destroyed. jQuery cleans up data and events on removal.

🚀 Common Use Cases

  • Dismiss alerts — hide error or success banners after the user reads them.
  • Collapse panels — animate sections closed with .hide("slow") for smoother UX.
  • Step wizards — hide the current step and show the next with .hide() / .show().
  • Loading states — hide spinners instantly when Ajax completes.
  • Self-hiding controls — hide a “Click to dismiss” link after interaction.
  • Animated removal — fade out list items, then .remove() in the callback.

🧠 How .hide() Hides Elements

1

Match target elements

jQuery collection identifies which nodes to hide.

Elements
2

Save display value

Current display cached so .show() can restore inline, block, flex, etc.

Cache
3

Hide instantly or animate

No duration → immediate display: none. With duration → animate size and opacity first.

Effect
4

Return jQuery collection

Same matched set returned for chaining — elements stay in DOM until you .remove() them.

📝 Notes

  • Available since jQuery 1.0; easing parameter added in jQuery 1.4.3.
  • No-argument form hides instantly — roughly like .css( "display", "none" ) but saves the old value.
  • "slow" = 600 ms, "fast" = 200 ms; numeric default when animating is 400 ms.
  • With duration 0 or jQuery.fx.off = true, animation is skipped.
  • Callback runs once per matched element, not once for the whole animation batch.
  • Hidden elements remain in the DOM — use .remove() to delete nodes.
  • Animating many elements at once may affect performance; profile if needed.

Browser Support

.hide() has been part of jQuery since 1.0+. It uses standard CSS display and jQuery's built-in effects engine — no browser-specific APIs. Works in all browsers supported by your jQuery build — IE6+ through modern evergreen browsers in legacy jQuery versions, and all current browsers in jQuery 3.x and 4.x.

jQuery 1.0+

jQuery .hide()

Universal visibility API across jQuery 1.x, 2.x, 3.x, and 4.x. Pair with .show() to restore saved display values and .toggle() for flip visibility UIs.

100% With jQuery loaded
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
.hide() Universal

Bottom line: Default choice when hiding elements while keeping them in the DOM for later .show().

Conclusion

The jQuery .hide() method hides matched elements instantly or with animation. Call it with no arguments for immediate invisibility, pass "slow", "fast", or a millisecond value to animate, and supply a callback to run code when each element finishes hiding.

Unlike raw display: none, jQuery remembers the original display mode so .show() can restore layout correctly. Next up: reveal hidden elements with .show().

💡 Best Practices

✅ Do

  • Use .hide() / .show() when you need to restore original display values
  • Pass a complete callback for chained animations or post-hide cleanup
  • Use instant .hide() for spinners and elements that should vanish immediately
  • Prefer CSS classes for responsive visibility when breakpoints differ
  • Set jQuery.fx.off = true in tests to skip animation delays

❌ Don’t

  • Confuse .hide() with .remove() — hide keeps nodes in the DOM
  • Animate hundreds of elements simultaneously without profiling performance
  • Assume hidden elements are removed from accessibility trees — manage ARIA separately
  • Use .css("display","none") when you plan to call .show() later
  • Rely on hide/show alone for complex motion — consider CSS transitions for modern UIs

Key Takeaways

Knowledge Unlocked

Six things to remember about .hide()

The visibility method that saves display for later restoration.

6
Core concepts
🎬 02

Animated

slow/fast

Fade
03

Callback

complete

Chain
04

vs .show()

Pair API

Toggle
💾 05

Saves display

Cache

Restore
06

Chain

jQuery

Return

❓ Frequently Asked Questions

.hide() hides matched elements by setting display to none. With no arguments it happens instantly. jQuery saves the element's original display value in its data cache so .show() can restore inline, block, flex, or other layout modes later. Returns the jQuery collection for chaining. Available since jQuery 1.0.
.css('display', 'none') only sets the CSS property. .hide() also stores the previous display value in jQuery's cache. When you later call .show(), jQuery restores the saved value — so an inline element becomes inline again instead of defaulting to block.
Yes. Pass a duration in milliseconds, or the strings 'slow' (600ms) or 'fast' (200ms). jQuery animates width, height, and opacity together, then sets display to none. You can also pass an options object or a complete callback. With no duration, the hide is instant.
.hide() makes elements invisible and removes them from layout (display: none). .show() reverses the process and restores the saved display value. They are complementary visibility methods — pair them for menus, modals, and toggle UIs.
No. Hidden elements stay in the document tree; they just do not occupy space or receive pointer events. Use .remove() or .detach() when you need to take nodes out of the DOM entirely. You can call .remove() inside a .hide() complete callback after animation finishes.
Set jQuery.fx.off = true globally. All jQuery effects, including .hide(), then run with zero duration — effectively instant. Useful in tests or when motion must be reduced for accessibility. Reset to false to re-enable animations.
Did you know?

If an element had display: inline before you called .hide(), jQuery saves that value. When you later call .show(), the element becomes inline again — not block. Raw .css( "display", "none" ) does not store this, which is why the jQuery hide/show pair is safer for mixed layout types. Setting jQuery.fx.off = true disables all effect durations globally, making every .hide( "slow" ) behave like instant .hide().

Next: jQuery .show() Method

Display matched elements instantly or with animation.

.show() 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.

6 people found this page helpful