The jquery library file is loaded before the BODY element and must wait for all DOM elements to load, delaying support for DOM operations, or not.
In the deferred wait load,Javascript provides an event for load, as follows:
Window.onload = function () {}; JavaScript waiting to load
$ (document). Ready (function () {}); jquery waits for load and ready differences to be loaded
|
Window.onload |
$ (document). Ready () |
timing of execution you have to wait for the page to finish loading (including pictures, etc.), then execute the JS code |
Just wait for the DOM structure in the Web page loading is complete, You can execute the JS code |
number of executions can only be executed once If the second time, then first execution will be overwritten can execute multiple times , nth times will not be on the overwrite   |
Shorthand scheme |
No |
$ (function () {}) |
In practical applications, window.onload is seldom used directly, as he waits for large elements such as images to be loaded before the JS code can be executed. Experience slow speed or there is a large picture to download, the page has been fully expanded, the picture is still slowly loading, then any of the page JS Interactive function in the state of suspended animation. And can only perform a single time in multiple development and team development will bring difficulties.
Write in the rear:
Hello everyone, I am currently working in the group-Kunming Branch, 2823060927 is my QQ What about Java, PHP, NodeJS, database problems can communicate with me.
Browser load mode: Window.onload and $ (document). Ready ()