Home >Web Front-end >JS Tutorial >Detailed explanation of the difference between JQuery's ready function and JS's onload_jquery

Detailed explanation of the difference between JQuery's ready function and JS's onload_jquery

WBOY
WBOYOriginal
2016-05-16 17:13:27840browse

The difference between JQuery's ready function and JS's onload:
1. Execution time
window.onload must wait until all elements in the page, including images, are loaded before it can be executed.
$(document).ready() is executed after the DOM structure is drawn, without waiting until it is loaded.


2. Different writing numbers
You cannot write multiple window.onloads at the same time. If there are multiple window.onload methods, only one will be executed.
$(document).ready() can be written at the same time Write multiple and all can be executed


3. Simplified writing
There is no simplified writing for window.onload
$(document).ready(function(){}) can be abbreviated as $(function(){});

" -//W3C//DTD HTML 4.01 Transitional//EN"

"http://www.w3.org/TR/html4/loose.dtd">

                                                                                                                                                           worse not have been the same? ;