RubyRedGrapefruit
RubyRedGrapefruit

Reputation: 12224

How can I use jQuery to set a div to be visible?

I have a div as part of a page that is rendered like this:

<div id="productdiv" style="visibility:hidden;">

Upon a certain event, I want this div to become visible.

The following does not work:

$("#productdiv").show();

What will work?

Upvotes: 0

Views: 48

Answers (6)

teewuane
teewuane

Reputation: 5734

$('.asdf').click(function(){
    $("#productDiv").css('visibility','visible');
});

Upvotes: 0

Nudier Mena
Nudier Mena

Reputation: 3274

you should try something like this

$("#productdiv").css("visibility","visible");

or use this to set multiple CSS properties for ALL matched elements:

   $("#productdiv").css({"visibility":"visible","font-size":"50px"});

Upvotes: 2

Nathan
Nathan

Reputation: 2775

$('div#productdiv:hidden').show();

Upvotes: 0

Ian Routledge
Ian Routledge

Reputation: 4042

The show function sets the display css attribute. Use $("#productdiv").css("visibility", "visible"); instead.

Upvotes: 0

The show method works for the display property, not the visibility property. Use, .css('visibility', 'visible')...

Upvotes: 0

Kundan Singh Chouhan
Kundan Singh Chouhan

Reputation: 14302

Use display:none; instead of visibility:hidden;

Example

Replace this :

<div id="productdiv" style="visibility:hidden;">

With

<div id="productdiv" style="display:none;">

Upvotes: 2

Related Questions