Showing posts with label jquery check hidden. Show all posts
Showing posts with label jquery check hidden. Show all posts

Wednesday, 16 November 2011

How to tell an element is visible with jQuery

To check if an element is visible
if( $('#foo').is(':visible') ) {
    // it's visible, do something
}
else {
    // it's not visible so do something else
}

To check if an element is hidden
if( $('#foo').is(':hidden') ) {
    // it's hidden, do something
}
else {
    // it's not hidden so do something else
}