How I can check if an element is hidden in jQuery?

The simplest and easiest way to find if an element is hidden or not is the following

You can use .is( selector ) method return true if at least one of these elements matches the given arguments.

Following  method return true if element is visible 

$('#someElement').is(":visible");  // return true if element is visible 

Following method return true if element is not visible on DOM

$('#someElement').is(":hidden");  // return true if element is not visible on DOM

 

if you want to show some element on click if element is hidden or hide element if element is visible you can use jQuery toggle method to perform these actions 
 

$('.someElement').click(function() {
  $('.meesage').toggle('slow');
});


 


Tags:

Share:

Related posts