jQuery :hidden Selector

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

What Is :hidden?

:hidden (since jQuery 1.0) selects elements that are hidden — they consume no space in the layout. Opposite of :visible.

Remember
$(":hidden")                    // all hidden elements
$("div:hidden")                 // hidden divs only
$("input:hidden")               // hidden inputs (type=hidden, etc.)
$("#panel *").filter(":hidden") // faster scoped pattern

// Counts as hidden:
// · display: none
// · input type="hidden"
// · width/height set to 0
// · a hidden ancestor
//
// NOT hidden (still take space):
// · visibility: hidden
// · opacity: 0
NeedUse
No layout space$(":hidden")
Takes layout space$(":visible")
Hide / show.hide() · .show()
Previous selector:header

How to Use :hidden

Find elements that take no space, then count, reveal, or read their values.

  1. Call $("div:hidden") or scope with $("#panel *").filter(":hidden").
  2. jQuery checks layout space (not only CSS “looks invisible”).
  3. Chain .show(), .each(), or read attributes as needed.
  4. Exclude noise with .not("script") when scanning body.
  5. Remember: during a hide animation, the element stays :visible until the end.
PieceRequired?Role
:hiddenYesMatch elements with no layout space
Base selectorNoLimit type — e.g. div:hidden
.filter(":hidden")NoRecommended performance pattern
Return value—jQuery set of hidden elements

Pseudocode

Pseudocode
call $(":hidden")   // or $("type:hidden") / .filter(":hidden")

for each candidate element:
    if it consumes no layout space
       (display:none, type=hidden, 0×0, or hidden ancestor):
        include it
    else if visibility:hidden or opacity:0 only:
        skip it  // still "visible" to jQuery

return the jQuery set

Cheat Sheet

Keep these rules next to :visible.

TopicDetail
Syntax$(":hidden") · $("div:hidden")
SincejQuery 1.0 (meaning refined in 1.3.2 and 3.x)
Opposite:visible
CSS?No — jQuery extension
Faster pattern$("#el *").filter(":hidden")
Not matchedvisibility:hidden · opacity:0
AnimationsHidden only after hide animation finishes

Live Preview

Toggle panels, then Run to see which ones match :hidden.

Panel A (visible)

Panel B (will hide)

Panel C (visibility:hidden — still :visible)

Prep hides B with .hide() and sets C to visibility:hidden. Only B should match :hidden.

Result
Ready — click Prep sample, then Run.

jQuery Examples

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

Example 1 — Count Hidden Elements and Show Divs

Official idea: tally hidden nodes, reveal hidden divs, count hidden inputs.

jQuery
var hiddenElements = $("body").find(":hidden").not("script");
$("#log").text("Found " + hiddenElements.length + " hidden elements.");
$("div:hidden").show();
$("#inputs").text("Hidden inputs: " + $("input:hidden").length);
Try It Yourself

How It Works

  1. Find. Scan body for :hidden matches.
  2. Exclude. .not("script") drops script nodes from the count.
  3. Show. $("div:hidden").show() reveals only hidden divs.
  4. Inputs. input:hidden counts form fields that take no space.

Example 2 — display:none vs visibility / opacity

Only no-space elements match. Invisible-but-spaced ones do not.

jQuery
$("#gone").hide();
$("#invisible").css("visibility", "hidden");
$("#transparent").css("opacity", 0);

$("#log").text(
  "display:none → " + $("#gone").is(":hidden") + "\n" +
  "visibility:hidden → " + $("#invisible").is(":hidden") + "\n" +
  "opacity:0 → " + $("#transparent").is(":hidden")
);
Try It Yourself

How It Works

  1. hide(). Sets display:none → no space → :hidden.
  2. visibility. Element still occupies layout → not :hidden.
  3. opacity. Fully transparent but still spaced → not :hidden.
  4. Rule. jQuery cares about layout space, not “can I see it.”

Example 3 — Performance: .filter(":hidden")

Official tip: CSS-select a region first, then filter hidden ones.

jQuery
var count = $("#panel *").filter(":hidden").length;
$("#report").text("Hidden inside #panel: " + count);
Try It Yourself

How It Works

  1. CSS first. $("#panel *") uses a fast native path.
  2. Filter. Keeps only descendants that are :hidden.
  3. Scope. Hidden nodes outside #panel are skipped.
  4. Why. Avoids a full-document jQuery-extension scan.

Example 4 — Form Fields: input:hidden

Read every hidden input’s name and value.

jQuery
var lines = [];
$("input:hidden").each(function () {
  lines.push(this.name + " = " + this.value);
});
$("#log").text(lines.join("\n"));
Try It Yourself

How It Works

  1. Match. type="hidden" inputs take no layout space.
  2. Skip. Visible text inputs are not included.
  3. Each. Read name and value from each match.
  4. Use. Handy for debugging tokens and ids in forms.

Example 5 — Reveal Hidden Panels

Select hidden sections and show them on a button click.

jQuery
$("#reveal-btn").on("click", function () {
  $("#accordion div:hidden").show();
});
Try It Yourself

How It Works

  1. Select. div:hidden inside the accordion only.
  2. Click. Button runs the reveal once.
  3. show(). Clears display:none on those matches.
  4. Open ones. Already-visible divs are not in the set.

Edge Cases & Pitfalls

These surprises come up often with “invisible” CSS.

space

visibility / opacity ≠ hidden

If the element still occupies layout space, it is :visible to jQuery.

anim

During hide animations it stays visible

While sliding/fading out, the element is still :visible until the animation ends.

ancestors

Hidden parent hides children

A child inside display:none is also :hidden, even if the child has no hide styles of its own.

jq3

jQuery 3: no layout box → hidden

br and empty inlines without boxes are considered :hidden in jQuery 3+.

perf

Heavy use can force layout

Official docs note visibility checks may reflow. Prefer a class flag or scoped .filter(":hidden").

Browser Support

:hidden has been part of jQuery since 1.0 (layout-space meaning clarified in 1.3.2; jQuery 3 refined empty/no-box cases). It works in every browser that runs your loaded jQuery version.

✓ Stable · jQuery 1.0+

jQuery :hidden

Supported across jQuery 1.x, 2.x, and 3.x. Prefer a current jQuery 3.x build and know the jQuery 3 layout-box nuance.

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
:hidden Universal

Bottom line: Safe everywhere jQuery runs. Scope or filter for performance, and do not confuse visibility/opacity with :hidden.

Performance Notes

ApproachCostBest for
$("#el *").filter(":hidden")BetterScoped checks (official tip)
$(":hidden") page-wideHeavierSmall pages / demos
Track a CSS class yourselfCheapestFrequent visibility toggles

Official docs warn that heavy :hidden use may force reflow. Prefer a class you control, or a CSS select plus .filter(":hidden").

Key Takeaways

  • Role: match elements that take no layout space.
  • Opposite: :visible — they never both match the same element.
  • Not enough: visibility:hidden / opacity:0 alone.
  • Speed: CSS select, then .filter(":hidden").

One line: :hidden means “no layout space” — not merely hard to see.

Frequently Asked Questions

:hidden selects elements that are hidden — they consume no space in the document layout. Common cases include display:none, input type="hidden", zero width/height, or a hidden ancestor. Available since jQuery 1.0.
No. Elements with visibility:hidden or opacity:0 still take up layout space, so jQuery treats them as visible. Only elements that consume no layout space match :hidden.
Yes. Every element selected by :hidden is not selected by :visible, and vice versa. They are complementary filters in jQuery.
No. It is a jQuery extension and cannot use native querySelectorAll(). Official docs recommend a CSS scope first, then .filter(":hidden") for better performance.
In some browsers, $("body").find(":hidden") can also match head, title, script, and other non-visible document nodes. The official demo excludes script tags before counting user-facing hidden elements.
Starting with jQuery 3, elements without layout boxes — such as br and empty inline elements — are considered :hidden. This slightly refines how :hidden and :visible divide the DOM.

Next: :visible Selector

Select elements that consume layout space — the opposite of :hidden.

:visible 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