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
Run Laravel queue workers with Supervisor
How to Run Laravel Queue Workers in Production with Supervisor
May 23, 2026
Nginx as a reverse proxy for a Node.js app on Ubuntu
How to Set Up Nginx as a Reverse Proxy for Node.js on Ubuntu
May 23, 2026
Install and configure Redis on Ubuntu for Laravel and WordPress
How to Install and Configure Redis on Ubuntu (for Laravel & WordPress)
May 23, 2026
Harden a fresh Ubuntu VPS with UFW, Fail2Ban, and SSH key auth
How to Harden a Fresh Ubuntu VPS: UFW + Fail2Ban + SSH Key Auth
May 23, 2026
Set up Let's Encrypt SSL with Certbot on Ubuntu
How to Set Up Let’s Encrypt SSL with Certbot on Ubuntu (Apache & Nginx)
May 23, 2026

You Might Also Like

Laravel unique validation that ignores the current record on update
Web Development

How to Validate a Unique Column on Update in Laravel

4 Min Read
WordPress admin notice — four notice types shown at the top of the admin area
Web Development

How to Show Custom Notifications in the WordPress Dashboard

6 Min Read
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
DataTables default sort order — order: [[1, 'desc']] config
Web Development

How to Change the Default Sort Order in DataTables

4 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?