Problem
If you work with JavaScript for a while you'll most likely have wanted to know whether a certain element is visible or not. While it's easy if you apply a class like hidden
or a style like display: none;
, it can get tricky with nested elements.
jQuery to the rescue!
Solution
Assuming you have an element like this:
<div id="myElement">
Am I hidden or not?
</div>
You can simply check for its visibility by using this code:
$("#myElement").is(":visible");
Comments