Hi Everyone, The first thing to learn about jQuery is $( document ).ready(): If you want an event to work on your page , you should call it inside the $(document).ready() function.
Diff between $( window ).load() and $(document).ready()
$( document ).ready() will only load once the page Document Object Model (DOM) is ready for JavaScript code to execute and before the page contents are loaded.
$( window ).load(function() { ... }) will run once the entire page (images or iframes), not just the DOM, is ready.
Diff between $( window ).load() and $(document).ready()
$( document ).ready() will only load once the page Document Object Model (DOM) is ready for JavaScript code to execute and before the page contents are loaded.
$( window ).load(function() { ... }) will run once the entire page (images or iframes), not just the DOM, is ready.
1 2 3 | $( document ).ready(function() { console.log( "DOM is ready!" ); }) |