tags:

views:

118

answers:

5

my style is here

#mybox{
display:none;
}

my web is here

<div id='mybox'>
...
</div>


<script type='text/javascript'>
  $(document).ready(function(){
   $("#mybox").css("display","visible");
})
</script>

mybox don't show. How to show mybox ?

+5  A: 

use $("#mybox").show() or $("#mybox").css("display","block");

Ghommey
+2  A: 

It is display: block in stead of display visible:

<div id='mybox'>
...
</div>


<script type='text/javascript'>
  $(document).ready(function(){
   $("#mybox").css("display","block");
})
</script>
Ikke
+2  A: 
$('#mybox').show();

or

$('#mybox').slideDown();
cballou
A: 

Firstly, "visible" isn't a valid value for the display attribute. Something like "block" or "inline" is. Secondly, don't set CSS directly like this. It's problematic. Instead use the jQuery effects for showing and hiding things (show/hide/toggle, slideUp/slideDown, fadeIn/fadeOut, etc):

$(function() {
  $("#mybox").show();
});

or alternatively use a class:

$(function() {
  $("#mybox").toggleClass("visible");
});

with:

div.visible { display: block; }
cletus
I find it useful to have an `hidden` class with `display: none;` - this can be applied to anything. Also, I think the `#mybox` css rule is stronger, so I'm not sure adding a class will show it.
Kobi
+1  A: 

If you use the CSS with display:none; on an element you can trigger .show() and .hide() with jQuery on it! This is a jQuery default feature.

powtac