1

I have these 2 div's !

<div id="loader">
</div>

and

<div id="wrapper">
</div>

"The wrapper div is not inside the loader div for any clarification"

My script

$(window).bind("load",function() {
           $('#loader').css('display',none);
           $('#wrapper').css('visibility',visible);
        });

What I intend to do with the script is to hide the loader div after the page has been completely loaded and display the wrapper div which contains all the contents of the page. I initially set display:none in the wrapper style.

As I expected the loader div is displayed but after the loading has been completed (which I can tell at least from the loading icon of the mouse and the favicon region of the browser tab) but the wrapper div is not shown .

Any help would be nice.

NoobEditor
  • 15,563
  • 19
  • 81
  • 112
Magesh Kumaar
  • 1,485
  • 2
  • 10
  • 29
  • You cannot see your wrapper-div, because you don't change it's `display` style-attribute! Also have a look at http://api.jquery.com/ready/ – ˈvɔlə Jan 15 '14 at 07:37

6 Answers6

5

You should use the $(document).ready() to load the page completely.

The following code may help you...

$(document).ready(function(){
    $('#loader').css('display','none');
    $('#wrapper').css('display','block');
});
Hasib Tarafder
  • 5,773
  • 3
  • 30
  • 44
1

Use this;

$(document).ready(function() {
           $('#loader').hide();
           $('#wrapper').show();
});

or

$(document).ready(function() {
           $('#loader').css('display','none');
           $('#wrapper').css('visibility','visible');
});

Working fiddle: http://jsfiddle.net/33zch/

Hüseyin BABAL
  • 15,400
  • 4
  • 51
  • 73
1

In some browsers, like Firefox, event $(window).load() apperas only after successfully loading all elements (images, for example), but in Chrome $(window).load() and $(document).ready() fired in same time. Using $(window).load() have potential issue in firefox (maybe in another browsers too): if at least one image on the page is loaded with error then event not occure. And use right syntax:

$('#loader').css('display','none');
$('#wrapper').css('display','block');

or

$('#loader').hide();
$('#wrapper').show();
Roman Izosimov
  • 210
  • 1
  • 9
0

It should be like this :-

$('#loader').css('display','none');
$('#wrapper').css('visibility','visible');
Anup
  • 9,396
  • 16
  • 74
  • 138
0

You can use with this simple way.

window.onload = $('#loader').hide();
window.onload = $('#wrapper').show();
Bharat soni
  • 2,686
  • 18
  • 27
0

You told that you have initially set wrapper element to display:none; Then how it will be visible by adding visibility:visible ? Instead you should add display:block to get this working.

Working Demo

Surjith S M
  • 6,642
  • 2
  • 31
  • 50