I’m running into a strange problem with testing an object’s visibility with jQuery.
I have this test JS:
alert($myObject.css('display'));
alert($myObject.is(':visible'));
The first alert displays ‘block’ which makes sense as firebug clearly shows that it is set to display: block and you can see the object on the page in the browser.
The second alert, though, displays ‘false’. Which doesn’t make any sense to me at all.
Am I misunderstanding the use of is(‘:visible’)?
Consider this HTML:
and this JavaScript:
There are multiple reasons
$myObjectmay not be visible, even though it hasdisplay: nonestyle set. See :visible selector docs for details.Does it make sense now?