본문 바로가기

Computer Programming/Javascript

JQuery - $( document ).ready()

A page can't be manipulated safely until the document is "ready." jQuery detects this state of readiness for you. Code included inside $( document ).ready() will only run once the page Document Object Model (DOM) is ready for JavaScript code to execute. Code included inside $( window ).on( "load", function() { ... }) will run once the entire page (images or iframes), not just the DOM, is ready.

 

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



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

 

 

https://learn.jquery.com/using-jquery-core/document-ready/

 

$( document ).ready() | jQuery Learning Center

A page can't be manipulated safely until the document is "ready." jQuery detects this state of readiness for you. Code included inside $( document ).ready() will only run once the page Document Object Model (DOM) is ready for JavaScript code to execute. Co

learn.jquery.com