Check If Any Form Element Is Hidden Using Jquery




Here we consider how to Check If Any Form Element Is Hidden Using Jquery. We already knows how to hide and show any form element using Jquery.

$('#ElementID').hide(); --- Hide Any Element

$('#ElementID').show(); --- Show Any Element




For Checking any element is hidden or not, we have two methods.




Here ElementID is the ID of the element that needs to be checked.

if (   $('#ElementID').is(":visible")   )
{
            // Element Is Visible - Not Hidden .
}
else
{
            // Element Is Not Visible - Hidden .
}




$('#ElementID').is(":visible") will check whether the element is Visible or not.





Second method uses Jquery css as shown below.

if (   $('#ElementID').css('display') != 'none'   )
{
            // Element Is Visible - Not Hidden .
}
else
{
            // Element Is Not Visible - Hidden .
}




$('#ElementID').css('display') != 'none' will check whether the element is Visible or not.