tags:

views:

119

answers:

3

I am trying to hide a div until document is ready - and then display it.

This is what I am trying to do:

<div id='initiallyhidden' style='visibility:hidden'>I am a secret - kinda!</div>

<script>
$(document).ready(function() {
    $("#initiallyhidden").show();
});

</script>

How can I make this work?

+4  A: 

Change your markup to:

<div id='initiallyhidden' style='display:none'>I am a secret - kinda!</div>
karim79
+4  A: 

Use the display: none; css property instead. Also, I put your style separately =)

<div id="initiallyhidden" class="hidden">I am a secret - kinda!</div>

<script>
$(document).ready(function() {
    $("#initiallyhidden").show();
});
</script>

<style type="text/css">
    .hidden { display: none; }
</style>
Tomas Lycken
+1  A: 

use display: none instead because it takes the element completely out of play, where as visibility: hidden keeps the element and its flow in place without visually representing its contents.

<div id='initiallyhidden' class='hide'>I am a secret - kinda!</div>

<style type="text/css">
  .hide { display: none; }
</style>
TStamper