Differences between jqueryready events and javascriptload events

Source: Internet
Author: User
& Lt;/pre & gt; & lt; prename & quot; code & quot; class & quot; javascript & quot; & gt; /** 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 on the page including images and other files are loaded...
/*
* 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 ),
* The second is onload, which indicates that all elements, including images and other files, on the page are loaded. (You can say: ready loads before onload !!!)
* Window. onload cannot be written at the same time. If there are multiple window. onload methods, only one
* $ (Document). ready () can be compiled at the same time and executed
* $ () Is short for $ ("document"). ready () method
*
* The following code pops up first: hello and then: test2
*/
Function test1 (){
Alert ("test1 ");
}
Function test2 (){
Alert ("test2 ");
}
Window. onload = test1;
Window. onload = test2;
/**
* To execute both functions: window. onload = function (){
Test1 ();
Test2 ()
}
*/
$ (Function (){
Alert ("hello ");
})

 
/**
* Differences between jquery and javascript variables: by default, when defining jquery object variables, you should add a $ variable before the variable
Differences between javascript Variables
*/
Var $ div = $ ("div"); // jquery variable
Var div = document. getElementsByTagName ("div"); // javascript Object variable
 


Window. onload = function (){
Var dom = document. getElementsByTagName ("");
For (var I = 0; I Dom [I]. onclick = function (){
Alert ("hello ");
}
}
}
Script



From all the way to the North
Related Article

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.