1

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 Answers 5

5

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

Sign up to request clarification or add additional context in comments.

Comments

3
$('#mybox').show();

or

$('#mybox').slideDown();

Comments

2

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>

Comments

1

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.

Comments

0

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; }

1 Comment

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.