• support@answerspoint.com

Checking if an element is hidden


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?



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

// Checks for display:[none|block], ignores visible:[true|false]
  • answered 7 years ago
  • Sunny Solu


You can use the hidden selector:

// Matches all elements that are hidden

And the visible selector:

// Matches all elements that are visible
  • answered 7 years ago
  • Gul Hafiz

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

Functions don't work with the visibility attribute.

  • answered 7 years ago
  • G John

Your Answer

    Facebook Share        
  • asked 7 years ago
  • viewed 1525 times
  • active 7 years ago

Best Rated Questions