Bobo $ (function () {}) and $ (document). Ready (function (){})

Source: Internet
Author: User
Document. differences between ready and onload-there are two types of events for loading a JavaScript document: Ready, indicating that the document structure has been loaded (excluding non-text media files such as images) the second is onload, which indicates that all elements on the page including images and other files are loaded. Many people who use JQ write scripts like this: $ (function () {// do something}); in fact, this is short for JQ ready (), which is equivalent:

 

$ (Document). Ready (function () {// do something}) // or the following method, the default parameter of jquer is: "document ";

 

$ (). Ready (function () {// do something}) the JQ ready () method is Dom ready. Its function or meaning is: after the Dom is loaded, you can operate the Dom. Generally, the loading order of a page response is: domain name resolution-loading HTML-loading JS and CSS-loading images and other information. Then Dom ready should be able to operate Dom between loading JS and CSS and loading other information such as images.

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.