Showing posts with label toggle(). Show all posts
Showing posts with label toggle(). Show all posts

Check element visibility with jquery


In jQuery, it is possible to toggle the visibility of an element. We can use the functions .hide(), .show() or .toggle().

 We can also check whether a element is hidden or visible using jQuery.

To check whether a element is visible or not you can use 

if(  $(element).is(":visible") )
 {
    //your code here
 }  

or you can also use

if(  $(element).css('display') == 'none'  )
{
     //your code here
 }

If you want to select all the elements which are hidden use this 

$('element:hidden')

If you want to select all the elements which are visible use this 

$('element:visible')

Read more...