Dom after the completion of the implementation, has not been understood, based on some of the online method of logic does not understand, so go to the jquery source code research (ready function) of this article, write the following code (already detailed)
Copy Code code as follows:
Because to compare with JQ, so the test time needs to import JQ library. The function itself is not invoked JQ, please be assured to reference.
The code
This article illustrates the execution order of multiple $ (document). Ready () in the form of an instance, where multiple $ (document) can be seen. The execution order of ready () is not a simple sequential execution and has a certain relationship with the nesting level. The specific example code is as follows:
Run alert display order: 1,4,6,2,5,7,3Readers can test their own experiences to deepen
have been studying jquery recently, this thing is still very broad and profound. Below share my summary of the study.
$ (document). Ready () method vs OnLoad event vs $ (window). Load () method
The first thing you learn about jquery is when you start an event. In the past a long time, the page loading after the events are loaded in the "body" of the onload incident.
For the body of the OnLoad event and jquery r
The question is simple, but difficult to answer.
We usually deliver the software on time and try to do all the development and testing work before the deadline. We will prioritize the parts that we feel are important, and when the application reaches the established quality standards, it is ready to go online. Because the content of the publication may not be perfect, we always assume that there will be some later versions. Even when we deliver the s
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 when the DOM structure is drawn and does not have to wait for the load to complete.2. Dif
Today, I have nothing to do with jquery. the internal implementation of ready () is confused by the source code of JQ. Because of the fact that I am very fond of cooking, I flipped through the podcast of the cool-man, telling details and gaining a lot.
First, popularize jquery. ready () and window. onload, window. the onload event is triggered after all resources on the page are loaded. if there are large i
Generally, the onload of the Body Tag is set to listen to the load event of the window. however, the load event is triggered only after all the elements on the page are loaded. If there are too many pages or the picture is too large, it will lead to initialization.
Code When not executed, the user performs other operations. the jquery Library provides a very convenient and useful function ($ (selector ). ready (), so that we can perform corresponding
This function mentioned three equivalent forms in jQuery's document:Copy codeThe Code is as follows:// Defined in jQuery. fn. ready$ (Document). ready (handler );// It is the same as the previous one and is not recommended.$ (). Ready (handler );// Process in the jQuery object separately$ (Handler );// The preceding definition:If (jQuery. isFunction (selector ){R
Page loading completed there are two kinds of events, one is ready, indicating that the document structure has been loaded complete, Onload,ready concept is easy to confuse, the following for everyone in detailPage loading completed there are two kinds of events, one is ready, indicating that the document structure has been loaded complete (not including pictures
This article mainly gives you detailed information on Jquery's implementation of ready and bind events. If you are interested, you can refer to this section before reviewing the previous Code:
(Function (win) {var _ $ = function (selector, context) {return new _ $. prototype. init (selector, context);} _ $. prototype = {Init: function (selector, context) {this. elements = []; var context = context | document; if (context. querySelectorAll) {var arr
$ (document). Ready () and window.onload on the form, we go to execute a function or action, but in the exact details, $ (document) And window.onload still have a difference, let me introduce the following.The most basic difference1. 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 execut
1. Execution Time Window.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 when the DOM structure is drawn and does not have to wait for the load to complete. 2. different writing numbers window.onloadNBSP; $ (document). Ready () can be written multiple at the same time and can be executed3.
jquery $ (document). Ready () method and Window.onload methodIn most cases, the jquery code is written that requires us to put the jquery code in the
$ (document). Ready (function () {
... jquery code ........ .....
});
The above code and
$ (). Ready (function () {
... jquery code ........ .....
});$ (function () {
... jquery code ........ .....
});
is
In jquery, we can see two ways of writing: $ (function () {}) and $ (document). Ready (function () {})Both of these methods have the same effect, which is to execute a function after the DOM document tree has been loaded (note that the document tree inside does not load all of the files).Instead, Window.onload executes a function after the DOM document tree has been loaded and all files have been loaded. That is, $ (document).
$ (document). Ready (...) and window.onload: events have a similar effect, but there are subtle differences in the time they are triggered.1.window.onload:The Window.onload event is triggered when a document is completely downloaded to the browser. This means that all the elements on the page are accessible to JavaScript, which is advantageous for writing functional code because there is no need to consider the order of loading.2.$ (document).
The first thing to learn about jquery is that if you want an event to run on your page, you must call this event in the (document). Ready (). All elements or events that are included in the. Ready () will load immediately after the DOM finishes loading and before the page content is loaded.If you want a event to work on your page, you should call it inside the $ (document).
Recently, when I changed a page embedded in the frame, jquery was used for the effect, and the page itself was bound with the onload event. After the change, the test in Firefox is normal and smooth. in IE, it takes more than a dozen seconds for jquery to show up, and daylily is getting cooler.
At first, we thought it was a conflict with the onload loading method. $ (Document) is widely used on the Internet ). ready () is executed after the DOM pa
Jqurey event ready method usage, jqureyready
Ready activates the function after the document is loaded.
Example:
Definition and usage:
When the DOM (Document Object Model) has been loaded and the page (including images) has been fully rendered, a ready event occurs.
Since this event occurs after the document is ready
There are two types of page loading events: ready, indicating that the file structure has been loaded (excluding non-text media files such as images), and onload, indicates that all elements, including images, are loaded. (You can say: ready loads before onload !!!)Generally, the style is controlled, and the slice size is controlled to be loaded in onload;The jS event trigger method can be loaded in
There are two types of page loading events: ready, indicating that the file structure has been loaded (excluding non-text media files such as images), and onload, indicates that all elements, including images, are loaded. (You can say: ready loads before onload !!!)
Generally, the style is controlled, and the slice size is controlled to be loaded in onload;
The jS event trigger method can be loaded in
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.