1 June 2014

$( document ).ready() in Jquery

$( document ).ready() in Jquery

$( document ).ready(function() {
    console.log( "ready!" );
});


is equal to

// Shorthand for $( document ).ready()
$(function() {
    console.log( "ready!" );
});


$( document ).ready() will only run once the page Document Object Model (DOM) is ready for JavaScript code to execute. Code included inside $( window ).load(function() { ... }) will run once the entire page (images or iframes), not just the DOM.



No comments:

Post a Comment

Comments Welcome