1. execution time
window.onload () to perform after that is written in jquery $ (window) .load (function ( ) {}) must wait until all the elements within the page, including images loaded.
$ (document) .ready () is executed after the DOM structure of the drawing is completed, without waiting to load.
2. Write the number of the different
window.onload can not write more, if there are multiple window.onload method will only execute a (last)
$ (the Document) .ready () can write multiple simultaneously, and can get performing
3. simplified written
window.onload does not simplify writing
$ (document) .ready (function ( ) {}) can be abbreviated to $ (function () {}
---------------- -----
copyright: this article is CSDN bloggers "stupid humans' original article, follow the CC 4.0 by-sa copyright agreement, reproduced, please attach the original source link and this statement
original link: https: // blog .csdn.net / shaleilei / article / details / 78230443
The jquery $ (document) .ready (function () {}) and $ (window) .load () Comparative
Guess you like
Origin www.cnblogs.com/zhangq/p/11344649.html
Recommended
Ranking