Puru Vijay Puru Vijay - 1 year ago 82
jQuery Question

jquery - removing loading div after the page has loaded

So I created a simple method to put a loader. I put a loader already and put the opacity of a main container tag to 0.4 . but when page loads, my javascript doesn't remove the loader and set opacity to 1. So my code here:

Important Notes:

I use JQuery version 2(I don't know the exact)

$(document).ready(function() {
$(this).load(function() {
$('body').css("opacity", "1");

Answer Source

You should use $(window).load() not $(document).load()

    alert("This can run");
    alert("This cannot run");
    alert("This cannot run too");
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download