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

Note: if the element doesn’t take up any space in the document, then is(‘:hidden’) will return true even if it is effectively visible. It may be safer to instead do this:

if( !$('#foo').is(':visible') ) {
    // it's hidden, do something
}
else {
    // it's not hidden so do something else
}
Advertisements