Reputation: 4476
I have a div
element <div id='someId' style="visibility: hidden;"></div>
$(#someId).css('visibility'); // returns "hidden" $(#someId).is(':hidden'); // returns false $(#someId).is(':visible'); // returns true
Is this a bug in JQuery 1.8 or I didn't figure out something ?
Upvotes: 2
Views: 208
Reputation: 68790
:hidden
selector can refers to :
display: none
type="hidden"
width: 0px; height: 0px
So visibility: hidden
doesn't enter in those cases.
See jQuery doc here : http://api.jquery.com/hidden-selector/
EDIT
To check visibility
property :
if($("#someId").css('visibility') == 'hidden') {
/* some code */
}
Upvotes: 3
Reputation: 20840
Please refer the following jquery links :
Here reason is clearly mentioned that Elements with visibility: hidden or opacity: 0 are considered visible, since they still consume space in the layout
Upvotes: 2
Reputation: 341
is(':visible') and is('hidden') takes the display Property as reference
Upvotes: 0
Reputation: 30453
From jquery.com:
Elements can be considered hidden for several reasons:
They have a CSS display value of none.
They are form elements with type="hidden".
Their width and height are explicitly set to 0.
An ancestor element is hidden, so the element is not shown on the page.
Upvotes: 1