1. execution time
Window. onload can only be executed after all elements including images in the page are loaded.$ (Document). Ready () is executed after the DOM structure is drawn. You do not have to wait until the loading is complete.
2. different numbers of codes
Window. onload cannot be written at the same time. If there are multiple window. onload methods, only one$ (
1. execution timeWindow. onload can only be executed after all elements including images in the page are loaded.$ (Document). ready () is executed after the DOM structure is drawn. You do not have to wait until the loading is complete.2. different numbers of codes Window. onload cannot be written at the same time. If there are multiple window. onload methods, only one$ (
jquery $ (document). Ready () is similar to the Window.onload method in traditional JavaScript, but differs from the window.onload approach.jquery $ (document). Ready () is similar to the Window.onload method in traditional JavaScript, but differs from the window.onload approach.1. Execution TimeWindow.onload must wait
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.jquery $ (document). Ready () is similar to the Window.onload method in traditional JavaScript, but differs from the window.onload approach.1. Execution TimeWindow.onload must wait until all the elements of the page that include the picture have been loaded before they can be executed.$ (
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.jquery $ (document). Ready () is similar to the Window.onload method in traditional JavaScript, but differs from the window.onload approach.1. Execution TimeWindow.onload must wait until all the elements of the page that include the picture have been loaded before they can be executed.$ (
jquery $ (document). Ready () is similar to the Window.onload method in traditional JavaScript, but differs from the window.onload approach.1. Execution TimeWindow.onload must wait until all the elements of the page that include the picture have been loaded before they can be executed.$ (document). Ready () is executed
executed in the order in which it was registered. Note that even the ready events that register different elements are executed in sequence.For example, the following code:$ (window). Ready (function () {Alert ("window");}); $ (document). Ready (
$ (Document ). ready () and window. onload is a function or action that is executed when a page is loaded, but in details $ (document ). ready () and window. onload is different. I will introduce it later.
Basic Differences
1. execution time
Window. onload can only be execut
$ (Document ). ready () and window. onload is a function or action that is executed when a page is loaded, but in details $ (document ). ready () and window. onload is different.
Basic Differences
1. execution time
Window. onload can only be executed after all elements in
The most basic difference
1. Execution time
Window.onload must wait until all elements of the page including the picture have been loaded before they can be executed.$ (document). Ready () is executed after the DOM structure has been drawn and does not have to wait until the load has finished.
2. Different number of writes
Window.onload cannot write multiple at the same time, if there are multiple windo
function type, and the method works by: Specify a function to execute time the DOM is fully loaded. That means that when the DOM finishes loading, it is executed. . Since only the state of the document is ready, the operation of the element is safe. $ (document).
jquery $ (document). Ready () is similar to the Window.onload method in traditional JavaScript, but differs from the window.onload approach.
1. Execution Timewindow.onload must wait until all the elements of the page that include the picture have been loaded before they can be executed. $ (document). Ready () is execu
!"); } /*Execute correctly*/Script>Body>HTML>The second is to put the event bindings in the Window.onload:DOCTYPE HTML>MetaCharSet= "Utf-8">HTML>Head> title>1-3title> Scripttype= "Text/javascript">window.onload= function() {document.getElementById ("Panel"). onclick= function() {alert ("The element has been loaded!"); } } Script>Head>Body>DivID= "Panel">Click Me.Div>Body>HTML>The third is
$ (document) Ready () and window onload on the surface of the page load we go to execute a function or action, but in the specific details on the $ (document) Ready () and window onload is still different.The most basic difference1. Execution timeWindow.onload must wait unti
recommended unless necessary.
Finally, let's talk about ready. The ready event can be added to any element, such as $ (window ). ready (fn);, $ (document ). ready (fn);, $ ("p "). ready (fn); and so on.
The
recommended unless necessary.
Finally, let's talk about ready. The ready event can be added to any element, such as $ (window ). ready (fn);, $ (document ). ready (fn);, $ ("p "). ready (fn); and so on.
The
.
Finally, let's talk about ready. The ready event can be added to any element, such as $ (window ). ready (fn);, $ (document ). ready (fn);, $ ("div "). ready (fn); and so on.
The ready
When reading a book, I noticed that the following two statements have the same efficacy. $ (function () {alert ("hello! ") ;}); $ (Document). ready (function () {alert (" hello! ") ;}); This special syntax is to replace $ () with $ (document ).
I said at the beginning, using Window.onload, the code is as follows:Scripttype= "Text/javascript">window.onload= function() {document.getElementById ("name"). InnerHTML="Shangao"; } Script>Head>Body> PID= "Name">My name is Aaron.P>Body>There is also the ability to use jquery to accomplish this:Scripttype= "Text/javascript">$ (document). Ready (
.
Finally, the Ready,ready event can be added to any element, such as $ (window). Ready (FN);, $ (document). Ready (FN);, $ ("div"). Ready (FN);
The ready event does not require that
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.