JQuery - If DIV ID is Visible

jquery, jquery-ui

Solution

If you're trying to just show a div which is hidden, then you don't actually need to do any checks at all:

$('#myDiv').show();

Regardless of its state beforehand, it'll end up visible now.

However, if you want to perform other actions depending on whether the content is visible or not, then you'll need to check:

if ($('#myDiv').is(":hidden")) 
// or
if ($('#myDiv:hidden').length) 
// or
if ($('#myDiv:not(:visible)')) {    // you get the idea...
    //perform your actions
}

Problem

I am trying to find out of a DIV is hidden or if it is exposed. This is the pseudocode: ``` if(DIV != VISIBLE) // not visible { show content } ``` Any JQuery Experts able to assist me? Thanks, Robert

Original source