Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I set a visible property of a div element to true or false in jquery?

Tags:

jquery

dom

css

I would like to be able to do this:

$(".panel").visible = true; 

but this doesn't work.

like image 609
bill Avatar asked Sep 30 '10 19:09

bill


People also ask

How do you make a Div visible in jQuery?

To toggle a div visibility in jQuery, use the toggle() method. It checks the div element for visibility i.e. the show() method if div is hidden. And hide() id the div element is visible. This eventually creates a toggle effect.

How do I make a div visible?

visibility = 'visible'; If you are using jQuery, you can do it even easier as long as you want to set the display property: $(elem). hide(); $(elem).

How do I make label visible true in jQuery?

You can then use the jQuery hide() and show() functions. Show activity on this post. Set the CSS property visibility to visible . Show activity on this post.


2 Answers

For the display CSS property, use .show(), .hide() or .toggle() to affect whether it displays, like this:

$(".panel").show(); //or to hide: $(".panel").hide(); //toggle show/hide $(".panel").toggle(); //or show/hide based on boolean: $(".panel").toggle(bool); 

For the visibility CSS property, you need to set it manually (jQuery is mostly built around display), using .css() like this:

$(".panel").css("visibility", "visible"); //or: $(".panel").css({ visibility: "visible"}); 
like image 96
Nick Craver Avatar answered Oct 14 '22 16:10

Nick Craver


For me this worked:

document.getElementById('my_elementid').style.visibility='visible'; 
like image 25
Marcel Verwey Avatar answered Oct 14 '22 16:10

Marcel Verwey