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
Image Rollover Using onMouseOver and onMouseOut
Check if a string ends with the given target string
How to check if an element or HTML tag exists using JavaScript?
How can I redirect the user from one page to another using jQuery or pure JavaScript?
How to define Global Variable in JavaScript?
Highlight and get the details of table row on click using JavaScript