Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jquery .show() not revealing a div with visibility of hidden

Basic jQuery question:

I am trying to reveal a div that has been marked as hidden using jQuery. But am not quite getting it

I've created a JSFiddle here: http://jsfiddle.net/VwjxJ/

Basically, I want to use style="visibility: hidden;" rather than style="display: none;" as I want the space of the hidden element to be maintained

Have tried using show(), fadeIn() etc but neither work (they do for style="display: none;")

what am I doing wrong?

like image 774
ChrisCa Avatar asked Aug 26 '11 12:08

ChrisCa


People also ask

How check DIV is hidden or not in jQuery?

Answer: Use the jQuery :visible Selector You can use the jQuery :visible selector to check whether an element is visible in the layout or not. This selector will also select the elements with visibility: hidden; or opacity: 0; , because they preserve space in the layout even they are not visible to the eye.

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.

How do you do show hide in jQuery?

Syntax: $(selector). hide(speed,callback);


2 Answers

If you have hidden it with visibility:hidden then you can show it with jQuery by

$(".Deposit").css('visibility', 'visible'); 

And in the fiddle you are missing jQuery. Here is a demo: http://jsfiddle.net/9Z6nt/20/

like image 112
Muhammad Usman Avatar answered Sep 23 '22 17:09

Muhammad Usman


According to JQuery documentation .show() "is roughly equivalent to calling .css('display', 'block'), except that the display property is restored to whatever it was initially." Set the style explicitly instead. You could use a CSS class

.hidden{     visibility: hidden; } .shown{     visibility: visible; } 

and set is using

$("#yourdiv").removeClass("hidden").addClass("shown"); 
like image 20
Polymorphix Avatar answered Sep 21 '22 17:09

Polymorphix