Tamas B. Tamas B. -4 years ago 154
jQuery Question

jQuery on page load event not working

I want to my text fade in when page is loaded, i tried with this code-

$(document).on("load", function () {
$("#div1").fadeIn();
});


Why this not working?
I'm using 3.1.1

Answer Source

You should be passing .on("load") on the window instead of the document:

$(window).on("load", function () {
    $("#div1").fadeIn();
});

Alternatively, you could call .ready() on the document:

$(document).ready(function () {
    $("#div1").fadeIn();
});
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download