Home > Article > Web Front-end > Detailed explanation of the difference between JQuery's ready function and JS's onload_jquery
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(){});
"http://www.w3.org/TR/html4/loose.dtd">