Reputation: 183729
HTML:
<div id="box">my box</div>
How come I can hide a visible div like this: http://jsfiddle.net/FfaVW/2/
CSS:
#box {
visibility:visible;
}
JS:
jQuery('#box').hide();
But I can't show an hidden div like this: http://jsfiddle.net/FfaVW/1/
CSS:
#box {
visibility:hidden;
}
JS:
jQuery('#box').show();
Upvotes: 4
Views: 248
Reputation: 2628
Dont Use visibility
CSS for Show
and Hide
Div
.
Instead Use Div
Hide using Css
you use Display:none
and For Show use Displan:Block
Show Following Links For example:
Hope this is helpful for you.
Upvotes: 0
Reputation:
jQuery show()
and hide()
alter the display
.
display modifies the flow of the elements on the screen.
visibility just deals with the fact that whether you can see it on screen or not, but it will take space.
check the difference: http://jsfiddle.net/XS4ca/3/
Upvotes: 0
Reputation: 33457
show() alters the display CSS property, not visibility.
It will show a display: none for example.
http://api.jquery.com/visible-selector/
Offers insight as to why jQuery behaves this way:
Elements with visibility: hidden or opacity: 0 are considered visible, since they still consume space in the layout.
Upvotes: 3