There are quite a few ways to check if an element is visible or hidden in jQuery.
Demo HTML for example reference
<div id="content">Content</div>
<div id="content2" style="display:none">Content2</div>
Use Visibility Filter Selector $('element:hidden')
or $('element:visible')
$('element:hidden')
: Selects all elements that are hidden.
Example:
$('#content2:hidden').show();
$('element:visible')
: Selects all elements that are visible.
Example:
$('#content:visible').css('color', '#EEE');
Read more at http://api.jquery.com/category/selectors/visibility-filter-selectors/
Use is()
Filtering
Example:
$('#content').is(":visible").css('color', '#EEE');
Or checking condition
if ($('#content').is(":visible")) {
// Perform action
}
Read more at http://api.jquery.com/is/