javascript tutorial - [Solved-5 Solutions] Hidden element - javascript - java script - javascript array
Problem:
How would we test if an element is visible or hidden ?
Solution 1:
Solution 2:
Solution 3:
Functions don't work with the visibility attribute.
Solution 4:
None of these answers address what we understand to be the question, which is what we was searching for, "How do I handle items that have visibility: hidden?"
. Neither :visible
nor :hidden
will handle this, as they are both looking for display per the documentation. As far as I could determine, there is no selector to handle CSS visibility. Here is how I resolved it (standard jQuery selectors, there may be a more condensed syntax):
Solution 5:
You can determine whether an element is collapsed or not by using the :visible
and :hidden
selectors.
If you're simply acting on an element based on its visibility, you can just include :visible
or :hidden
in the selector expression. For example: