I have the following code:
$('#loading').css("visibility", "visible");
$('#loading').show();
For some reason unknown to me when I use the CSS it works!
But when I use .show();
It does not work. Please kindly help. I am a new to JQuery.
Thank you.
Edit:
<div class="footerOrder" id="loading" style="visibility:visible;">
<img src="../utils/loadingExistenz.gif" width="32" height="32" border="0" />
</div>
Tried this:
<div class="footerOrder" id="loading" style="display:block;">
Then:
$('#loading').hide();
And still no go for some reason!
EDIT: Weird thing is it is working for all the other DIVs!!
I would stick with putting
visibility: hidden;
on the element and then use.css("visibility", "visible");
to show it precisely because it still takes up space on the page.That will avoid jittery pages while loading and the dreaded Flash of Unseen Content (FOUC).
jQuery
.show()
requires to havedisplay:none
css propertyjQuery's
.show()
and.hide()
only operate on the CSSdisplay
property, not on thevisibility
property. I just checked the jQuery 1.7 source code and verified that is the case.So,
.css('display', 'none')
would be matched with.show()
.If you want to change the visibility, you would just change the css directly or make your own
hideV()
andshowV()
methods to do it for you:Use
display:none;
instead of visibilityThis works fine for me
Working sample : http://jsfiddle.net/HShHg/6/
According to the docs:
.show() This is roughly equivalent to calling .css('display', 'block')
so if you messed up with the
visibility
, it won't help you.What you should do is, always hide with
.css('display', 'none')
or with.hide()
I've Just found this useful docs: