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/



Have Questions? Post them here!



Recent Posts:




Code2care is an initiative to publish and share varied knowledge in programming and technical areas gathered during day-to-day learnings and development activities.

Students and Software Developers can leverage this portal to find solutions to their various queries without re-inventing the wheel by referring to our easy to understand posts. Technical posts might include Learnings, Video Tutorials, Code Snippets, How Tos, Blogs, Articles, etc.