Use Visibility Filter Selector
<script>
$(document).ready(function() {
var isVisible = $('#visibleElement').is(':visible'); // True
var isHidden = $('#hiddenElement').is(':hidden'); // True
});
</script>
Complete Example
<!DOCTYPE html>
<html lang="en">
<head>
<style>
#hiddenElement {
display: none;
}
#visibleElement {
display: block;
}
</style>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js"></script>
<script>
$(document).ready(function() {
var isVisible = $('#visibleElement').is(':visible'); // True
var isHidden = $('#hiddenElement').is(':hidden'); // True
});
</script>
</head>
<body>
<div id="hiddenElement">
Test
</div>
<div id="visibleElement">
Test
</div>
</body>
</html>
Most Helpful This Week
How to define Global Variable in JavaScript?
Generate random password for form field on click using JavaScript
Get largest number from each sub-arrays
How to change the height of Textarea on click?
jQuery simple form with name and email validations
JavaScript check if first string contains all characters of second string