How7o
  • Home
  • Tools
  • Prank Screens
  • Learn
  • Blog
  • Contact
Reading: How to Check if an Element Is Hidden or Visible with jQuery
Share
How7oHow7o
Font ResizerAa
  • OS
Search
  • Home
  • Tools
  • Prank Screens
  • Learn
  • Blog
  • Contact
Follow US
© 2024–2026 How7o. All rights reserved.
How7o > Free Laravel, PHP, WordPress & Server Tutorials > Web Development > How to Check if an Element Is Hidden or Visible with jQuery
Web Development

How to Check if an Element Is Hidden or Visible with jQuery

how7o
By how7o
Last updated: May 22, 2026
4 Min Read
Check if an element is hidden or visible with jQuery
SHARE

To check if an element is hidden or visible with jQuery, use $(el).is(':visible') or $(el).is(':hidden'). These match jQuery’s definition of visible: the element has non-zero size and isn’t display: none (nor is any ancestor). They don’t account for visibility: hidden or opacity: 0 — you have to check those separately.

Contents
  • TL;DR
  • What :visible actually checks
  • Strict-mode check
  • Vanilla JS equivalent
  • Frequently asked questions
  • Related guides
  • References

Last verified: 2026-05-17 with jQuery 3.7+. Originally published 2023-01-04, rewritten and updated 2026-05-17.

TL;DR

// Standard jQuery check
if ($('#panel').is(':visible')) {
  // visible to the user (display ≠ none, ancestors visible, non-zero size)
}

if ($('#panel').is(':hidden')) {
  // hidden (display: none somewhere up the chain, or zero size)
}

// Strict check — also catches visibility:hidden and opacity:0
function isReallyVisible($el) {
  return $el.is(':visible')
      && $el.css('visibility') !== 'hidden'
      && $el.css('opacity')    !== '0';
}

What :visible actually checks

  • The element has non-zero width or height.
  • No display: none on the element or any ancestor.
  • Elements with visibility: hidden are still considered visible.
  • Elements with opacity: 0 are still considered visible.

So :visible is really “occupies space and isn’t display:none-d.” For the everyday case (“is this panel shown right now?”) that’s the right semantics.

Check element visibility in jQuery — :visible covers display, doesn't cover visibility/opacity

Strict-mode check

For cases where invisible-but-still-occupying-space counts as “hidden” (form fields you’ve made visibility:hidden instead of removing, opacity-faded overlays), build a composite:

function isReallyVisible($el) {
  return $el.is(':visible')
      && $el.css('visibility') !== 'hidden'
      && parseFloat($el.css('opacity')) > 0;
}

Vanilla JS equivalent

function isVisible(el) {
  if (el.offsetParent === null) return false;        // display:none somewhere
  const cs = getComputedStyle(el);
  return cs.display    !== 'none'
      && cs.visibility !== 'hidden'
      && parseFloat(cs.opacity) > 0;
}

Frequently asked questions

Does :visible account for visibility: hidden?

No. jQuery’s :visible only checks the rendered box — width/height/display. An element with visibility: hidden still occupies space and is considered visible by :visible. If you need a stricter check, combine: $(el).is(':visible') && $(el).css('visibility') !== 'hidden'.

What about opacity: 0?

Same answer — :visible doesn’t check opacity. An element at opacity: 0 is invisible to the user but visible to jQuery. Add an explicit opacity check if that matters: $(el).css('opacity') !== '0'.

Why might :visible return false for an element that I can see?

Common cause: the element is inside a hidden parent. jQuery walks the ancestor chain — if any ancestor is display: none, the child is reported as hidden even if it has no display: none itself. That’s usually the right answer, but it surprises people writing per-element checks.

How do I check visibility without jQuery?

el.offsetParent !== null works for most cases — returns null when the element or an ancestor is display: none. For the full picture, use getComputedStyle: const cs = getComputedStyle(el); cs.display !== 'none' && cs.visibility !== 'hidden' && cs.opacity !== '0'.

Related guides

  • How to Check if a Bootstrap Modal Is Open or Closed with jQuery
  • How to Check if a Checkbox Is Checked with jQuery
  • How to Break Out of a jQuery .each() Loop

References

jQuery :visible selector: api.jquery.com/visible-selector. :hidden selector: api.jquery.com/hidden-selector.

TAGGED:CSSJavaScriptjQuery

Sign Up For Daily Newsletter

Be keep up! Get the latest breaking news delivered straight to your inbox.
[mc4wp_form]
By signing up, you agree to our Terms of Use and acknowledge the data practices in our Privacy Policy. You may unsubscribe at any time.
Share This Article
Facebook Copy Link Print
Previous Article jQuery check if a checkbox is checked How to Check if a Checkbox Is Checked with jQuery
Next Article Check Linux OS name and version from the command line How to Check the Linux OS Name and Version from the Command Line
Leave a Comment

Leave a Reply Cancel reply

You must be logged in to post a comment.

FacebookLike
XFollow
PinterestPin
InstagramFollow
Most Popular
Set vi as the default editor in Ubuntu — a terminal opening the vim editor
How to Set vi (Vim) as the Default Editor in Ubuntu
June 8, 2026
rsync says ALL DONE but files are missing — a terminal showing ALL DONE next to an empty folder
rsync Says “ALL DONE” but Files Are Missing: How to Verify
June 8, 2026
Migrate a website to a new server with rsync — files copying from an old server to a new one over SSH
How to Migrate a Website to a New Server With rsync
June 8, 2026
Bun runtime — faster JS toolkit replacing npm in Laravel projects
How to Install Bun Runtime on Ubuntu (And Use It in a Laravel Project)
May 24, 2026
Tailscale mesh — peer-to-peer connections between devices, coordination server
How to Install Tailscale on Ubuntu (Zero-Config Mesh VPN for Self-Hosters)
May 24, 2026

You Might Also Like

Laravel global variable for views — View::share in AppServiceProvider and View::composer wildcard patterns
Web Development

How to Set a Global Variable for Laravel Views

7 Min Read
JavaScript check HTTP referrer — document.referrer
Web Development

How to Check the HTTP Referrer with JavaScript

4 Min Read
Configure WordPress multisite with subdirectories on Nginx — nginx gear + wordpress tree with subsite branches
Web Development

How to Configure WordPress Multisite with Subdirectories on Nginx

12 Min Read
Run Laravel queue workers with Supervisor
Web Development

How to Run Laravel Queue Workers in Production with Supervisor

12 Min Read
How7o

We provide tips, tricks, and advice for improving websites and doing better search.

Tools

  • Age Calculator
  • Word Counter
  • Image Upscaler
  • Password Generator
  • QR Code Generator
  • See all tools→

Pranks

  • Fake Blue Screen Prank
  • Hacker Typer
  • Fake iMessage Generator
  • Windows XP Crash Prank
  • Windows 11 Update Prank
  • See all prank screens →

Company

  • About Us
  • Blog
  • Contact
  • Privacy Policy
  • Terms of Service
  • Sitemap
© 2024–2026 How7o. All rights reserved.
Welcome Back!

Sign in to your account

Username or Email Address
Password

Lost your password?