$ (Document ). ready (function () {}) indicates that the DOM document structure is loaded and jQuery. js is also executed after loading, excluding images and other non-text media resources, $ (document ). ready (fu
$ (Document). ready (function (){})Indicates that the DOM document structure is loaded and jQuery. js is also executed after loading, excluding images and other non-text media resources, $ (document ). the scaling method of ready (function () {}) is as follows:
$ (Function () {...}) and $ (). ready (function (){...})
Window. onloadIt indicates that the page and all resources including images are loaded and executed.
At this level, $ (document). ready (function () {}) is much better than window. onload, because the Loading Order of a page is as follows:Domain name resolution-loading html-loading js and css-loading ImagesAnd other information.
Note the following special cases:
Because $ (document ). ready (function (){...}) it starts execution once the DOM node is loaded. But how to reference other JS scripts on the page and modify some DOM node structures? $ (document) at this time ). ready (function (){..}) the actual node may not be detected. Of course, you can use setTimeout () or setInterval to solve the problem.