Window.onload must wait until all the elements of the page that include the picture have been loaded before they can be executed. ------> Cannot write multiple (if there are multiple, only one will be executed)
$ (document). Ready () is executed when the DOM structure is drawn and does not have to wait for the load to complete. -------> can write multiple----> with $ (function () {});
$ (document). Ready (function() { // Execute code }), or $ (function () { // execute code });
$ (document). Ready (function() {...}); /This time, do not have to wait for all the JS and pictures loaded, you can execute some methods, but sometimes, must wait for all the
Elements are loaded, before you can execute some methods, for example, some pictures or what other aspects have not been loaded well, this time, click on certain buttons, will lead to unexpected situations, this time, need to use:
$ (window). Load (function () { $ ("#btn-upload"). Click (function () { // For example, Uploadphotos (); } );
The ready difference between onload and jquery in JS