How to check if an element is hidden using jQuery code?


If we are writing some code using jQuery and want to know if a particular element in your page is visible or hidden you can do that using is() method,

Code Example:

<div id="hiddenEle" name="hiddenEle" style="display:none">This div is hidden</div>
<div id="visibleEle" name="visibleEle" style="display:block">This div is visible</div>
console.log($('#hiddenEle').is(":visible"));
console.log($('#visibleEle').is(":visible"));
Output:

false
true

Example - jQuery check if element is hidden
Example - jQuery check if element is hidden

✌️jsfiddle: https://jsfiddle.net/0wxy8ect/4/


🎉 We are celebrating the 10th years of Code2care! Thank you for all your support!

We strongly support Gender Equality & Diversity.

Follow Us: GitHub | Facebook | Twitter | Instagram