Friday, 4 April 2014

jquery event differences

document.ready event :

document.ready event will fire whenever DOm is loaded

window.load event :

window.load event will fire after loading all assets(images,Iframes etc) of webpage.

 <script src="" type="text/javascript"></script>
        //first DOM will load
            $('document').ready(function() {
                alert('DOM loaded');
        //in this program, after image will load this event will fire.
            $(window).load(function() {
                alert("window loaded");
     <img src="" />


$(document).ready(function () {
    $(document.body).css('background-color', 'silver');

$(window).load(function () {
    alert('this will alert after all the window resources completly loaded');
    $(document.body).css("background-color", "green");

No comments:

Post a Comment