-
Notifications
You must be signed in to change notification settings - Fork 2
Check If An Element Is Hidden Using JQuery
If you need to check the visibility status of some element on the page, you can do that easily with jQuery library with the simple block of code like the one below.
var display = ( jQuery('#someElement').is(':visible') );
var visibility = ( jQuery('#someElement').css('visibility') != 'hidden' );
var status = ( display && visibility );
console.log( status );
So, if the element is currently visible on the page the console.log(status)
would return true
and in any other case it would return false
. The false
statement would be returned for this two cases:
- if element has
display:none;
- if element has
visibility: hidden
and for more advanced checking like this: is the element visible on the viewport now I would recomend to use jQuery onScreen plugin
Learn to code and help nonprofits. Join our open source community in 15 seconds at http://freecodecamp.com
Follow our Medium blog
Follow Quincy on Quora
Follow us on Twitter
Like us on Facebook
And be sure to click the "Star" button in the upper right of this page.
New to Free Code Camp?
JS Concepts
JS Language Reference
- arguments
- Array.prototype.filter
- Array.prototype.indexOf
- Array.prototype.map
- Array.prototype.pop
- Array.prototype.push
- Array.prototype.shift
- Array.prototype.slice
- Array.prototype.some
- Array.prototype.toString
- Boolean
- for loop
- for..in loop
- for..of loop
- String.prototype.split
- String.prototype.toLowerCase
- String.prototype.toUpperCase
- undefined
Other Links