Ticket #4223 (closed bug: wontfix)
:visible,:hidden doesn't take visibility into account
| Reported by: | Akzhan | Owned by: | john |
|---|---|---|---|
| Priority: | major | Milestone: | 1.4 |
| Component: | selector | Version: | 1.3.2 |
| Keywords: | :visible, :hidden, visibility | Cc: | |
| Blocking: | Blocked by: |
Description
:visible and :hidden selectors doesn't take CSS visibility attribute into account.
Reported by habr-user Octane.
Sample code:
<html> <head> <script src="jquery-1.3.2.js"></script> <script> $(function() {
$('#test').css('visibility', 'hidden'); var visible = $('#test').is(':visible'); → true var hidden = $('#test').is(':hidden'); → false alert([visible, hidden]);
}); </script> </head> <body>
<div id="test">test</div>
</body> </html>
Change History
comment:2 Changed 4 years ago by dmethvin
It's mostly about what makes sense and how it's documented.
An opacity:0 has the same net effect as visibility:hidden, should that return false as well? What about an element positioned left: -1000px, top:-1000px which is out of the view port and thus "invisible"?
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

Additional remark:
visibility CSS style attribute doesn't affect offsetWidth/offsetHeight properties.