Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JQuery Visible Show

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!!

like image 402
iTEgg Avatar asked Mar 17 '12 21:03

iTEgg


People also ask

How do I set visibility visible in jQuery?

visible = function() { return this. each(function() { $(this). css("visibility", "visible"); }); }; }(jQuery));

What does show () do in jQuery?

The show() Method in jQuery is used to display the hidden and selected elements. Note: This method display the hidden elements which are using CSS display: none property. The elements are not visible whose visibility is hidden.

Is visible in jQuery?

The :visible selector in jQuery is used to select every element which is currently visible. It works upon the visible elements. The elements that are consuming space in the document are considered visible elements. The height and width of visible elements are larger than 0.

Is div visible jQuery?

You can use .is(':visible') selects all elements that are visible.


1 Answers

jQuery's .show() and .hide() only operate on the CSS display property, not on the visibility 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() and showV() methods to do it for you:

jQuery.fn.showV = function() {     this.css('visibility', 'visible'); }  jQuery.fn.hideV = function() {     this.css('visibility', 'hidden'); } 
like image 197
jfriend00 Avatar answered Sep 24 '22 13:09

jfriend00