• support@answerspoint.co.in

Checking if an element is hidden

2201
Advertisement

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

Using jQuery, how would you test if an element is visible or hidden?

3Answer


0

Since the question refers to a single element, this code might be more suitable:

// Checks for display:[none|block], ignores visible:[true|false]
$(element).is(":visible"); 
  • answered 11 years ago
  • Sunny Solu

0

You can use the hidden selector:

// Matches all elements that are hidden
$('element:hidden')

And the visible selector:

// Matches all elements that are visible
$('element:visible')
  • answered 11 years ago
  • Gul Hafiz

0
if ( $(element).css('display') == 'none' ){
    // element is hidden
}

Functions don't work with the visibility attribute.

  • answered 11 years ago
  • G John

Your Answer

    Facebook Share        
       
  • publish 11 years ago
  • viewed 2201 times
  • active 11 years ago

Best Rated Questions