Using JQuery To See If An Element Is Visible

jQuery can tell us if an element is currently set to visible. This will not tell us if the element is on the screen. It just means that the CSS properties of it and all of its parents are set to "visible".

Example (jQueryIsVisible.js):


if ( $(element).is(":visible") ) {
	// ... it and its parents are visible ...
} else {
	// ... invisible ...
}





The check is for display:[none|block] and it ignores visible:[true|false]. This means that $(element).hide(); will make the element not-visible and $(element).show(); will make it visible.

This will tell you if the element is currently on the screen.

This checks to see if the element is off of the screen.


•       •       •       •       •       •

Summary: # of Words: 154
Author: Philip J. Schlump
Published On: 2013-10-24

Download code from this articles in .tar.gz for Mac/Linux/Unix or .zip with CR/LF for Windows format.

 

Before You Go....

Have you read "Unintend Consinsequences"?

"I laughed so hard it hurt..."
    Rod Brown

"Incredibly funny! Incredibly true!"
    Tad Stevens