Document. differences between ready and onload-there are two types of events for loading a JavaScript document: Ready, indicating that the document structure has been loaded (excluding non-text media files such as images) the second is onload, which indicates that all elements on the page including images and other files are loaded. Many people who use JQ write scripts like this: $ (function () {// do something}); in fact, this is short for JQ ready (), which is equivalent:
$ (Document). Ready (function () {// do something}) // or the following method, the default parameter of jquer is: "document ";
$ (). Ready (function () {// do something}) the JQ ready () method is Dom ready. Its function or meaning is: after the Dom is loaded, you can operate the Dom. Generally, the loading order of a page response is: domain name resolution-loading HTML-loading JS and CSS-loading images and other information. Then Dom ready should be able to operate Dom between loading JS and CSS and loading other information such as images.