jQuery .hide() Method

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

What Is .hide()?

.hide() hides matched elements with display: none (since jQuery 1.0). Instant with no args; with a duration it becomes an animation. The previous display is saved for .show().

Remember
$(".target").hide()                 // instant
$("p").hide("slow")                 // 600ms animation
$("#box").hide(400, function () {   // ms + complete
  // this = current element
});

// "fast" = 200ms · default animated duration = 400ms
NeedUse
Hide now$(el).hide()
Show again$(el).show()
Flip visibility$(el).toggle()
Fade out only$(el).fadeOut()

How to Use .hide()

Select elements, then hide instantly or with a duration.

  1. Select the element(s) to hide.
  2. Call .hide() for an instant hide, or pass a duration / options.
  3. Optionally pass a complete callback (runs once per element).
  4. Restore later with .show() — saved display comes back.
PieceRequired?Role
Matched setYesElements to hide
durationOptionalms, "slow", or "fast"
easingOptional"swing" or "linear" (1.4.3+)
completeOptionalRuns after each element finishes

Pseudocode

Pseudocode
for each matched element el:
    save current display value in jQuery data

    if no duration (or duration is 0):
        set display = none          // instant; skips queue
    else:
        animate width, height, opacity → 0
        then set display = none
        call complete(this = el) once per element

return original matched set

// .show() restores the saved display value

Cheat Sheet

Keep these facts handy while toggling visibility.

TopicDetail
Instant.hide()
Animated.hide(duration[, easing][, complete])
SincejQuery 1.0 (easing arg 1.4.3)
Durations"fast" 200 · default 400 · "slow" 600
vs cssSaves display for correct .show()
DOMElement stays; layout space gone
Global offjQuery.fx.off = true

Live Preview

Hide the sample box instantly, slowly, or show it again.

Browser demo of .hide() / .show() — same idea as the examples below.

Hello — I am the target box.

Result
$("#box").hide()
→ display becomes none (instant)

jQuery Examples

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

Example 1 — Instant Hide

Hide paragraphs immediately with no animation.

jQuery
$("p").hide();
Try It Yourself

How It Works

  1. Select. $("p") matches every paragraph.
  2. Save. Each element’s current display is cached.
  3. Hide. display becomes none with no animation.
  4. DOM. Nodes remain queryable; they just leave layout.

Example 2 — Hide With "slow"

Animate the hide over about 600 milliseconds.

jQuery
$("p").hide("slow");
Try It Yourself

How It Works

  1. Duration. "slow" means 600ms.
  2. Animate. Width, height, and opacity move toward 0.
  3. Finish. jQuery sets display: none.
  4. Queue. Animated hides join the effects queue (unlike duration 0).

Example 3 — Hide Then Show

Prove that saved display is restored correctly.

jQuery
$("#box").hide();
$("#box").show();
// display restored from jQuery's cache
Try It Yourself

How It Works

  1. Hide. Caches display and sets none.
  2. Show. Reads the cache and restores that value.
  3. Why it matters. Inline stays inline — not forced to block.
  4. Pair. Use with .toggle() for on/off UIs.

Example 4 — Hide, Then Remove

Run cleanup in the complete callback after the animation.

jQuery
$("#box").hide(400, function () {
  $(this).remove();
});
Try It Yourself

How It Works

  1. Animate. 400ms hide runs first.
  2. Callback. Fires when that element finishes.
  3. this. Inside the function, this is the DOM element.
  4. Remove. .remove() deletes it after the visual hide.

Example 5 — Hide On Click

Hide paragraphs on load; hide the link when the user clicks it.

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

How It Works

  1. Load. $("p").hide() hides every paragraph instantly.
  2. Link stays. The <a> is not a paragraph, so it remains visible.
  3. Click. preventDefault stops navigation; $(this).hide() hides the link.
  4. Pattern. Same idea as the official jQuery .hide() click demo.

Edge Cases & Pitfalls

Check these before hiding large or responsive UIs.

css

Prefer .hide() over raw display:none

Raw CSS skips the display cache. Later .show() may restore the wrong layout mode.

queue

Instant hide skips the queue

No duration (or 0) runs immediately and can override queued animations.

a11y

Hidden ≠ removed from a11y tree always

display:none hides from layout and usually from assistive tech. Still manage focus when hiding open dialogs.

fx

jQuery.fx.off forces instant

When effects are off globally, animated .hide() becomes duration 0 — plan for that in tests.

Browser Support

.hide() has been part of jQuery since 1.0. The easing argument arrived in 1.4.3. It works wherever your loaded jQuery version runs.

✓ Stable · jQuery 1.0+

jQuery .hide()

Supported in all browsers that run jQuery 1.0+. Prefer a current jQuery 3.x build for modern projects.

100% jQuery core method
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: Safe for everyday UI. Prefer instant hide for large sets; animate only when motion helps understanding.

Performance Notes

ApproachCostBest for
.hide() instantCheapBulk hide, tables, lists
.hide("slow")Layout + paintSingle panels, feedback
Many animated hidesExpensiveAvoid — batch or use CSS classes

Instant hide is fine at scale. Animated hide on dozens of nodes can jank — animate one container instead of every child.

Key Takeaways

  • Role: set display: none and remember the old display.
  • Pair: restore with .show() or flip with .toggle().
  • Animate: pass duration / "slow" / "fast".
  • Not remove: nodes stay in the DOM until you .remove().

One line: .hide() is the jQuery way to take elements out of layout while keeping a correct path back via .show().

Frequently Asked Questions

.hide() hides matched elements with display: none. With no arguments it is instant. jQuery saves the previous display value so .show() can restore inline, block, flex, and other modes. Returns the jQuery collection for chaining. Available since jQuery 1.0.
.css("display", "none") only sets CSS. .hide() also stores the previous display in jQuery’s cache so .show() can restore it correctly.
Yes. Pass a duration in ms, or "slow" (600) / "fast" (200). jQuery animates width, height, and opacity, then sets display to none. You can also pass easing, an options object, or a complete callback.
No. Hidden elements stay in the document; they just leave layout. Use .remove() or .detach() to take nodes out of the DOM.
.hide() makes elements invisible and removes them from layout. .show() reverses that and restores the saved display value.
Set jQuery.fx.off = true. All effects, including .hide(), run with zero duration. Useful for tests or reduced motion.
Once per matched element when that element’s animation finishes — not once for the whole set.

Next: .show()

Restore hidden elements and the display mode jQuery saved for you.

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

8 people found this page helpful