Why can I .hide () but not .show () in jQuery?
HTML:
<div id="box">my box</div>β Why can I hide the visible div as follows: http://jsfiddle.net/FfaVW/2/
CSS:
#box { visibility:visible; }β JS:
jQuery('#box').hide();β But I can not show the hidden div as follows: http://jsfiddle.net/FfaVW/1/
CSS:
#box { visibility:hidden; }β JS:
jQuery('#box').show();β show () changes the CSS display property, not visibility.
The display will appear: no, for example.
http://api.jquery.com/visible-selector/
Suggests to understand why jQuery behaves as follows:
Elements with visibility: hidden or opaque: 0 are considered visible because they still consume space in the layout.
jQuery show() and hide() change display .
changes the flow of elements on the screen.
visibility only deals with the fact that you can see it on the screen or not, but it will take up space.
check the difference: http://jsfiddle.net/XS4ca/3/