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

Source: Internet
Author: User
The difference between Document.ready and onload--javascript document load Completion event page load complete there are two kinds of events, one is ready, the document structure has been loaded complete (not including pictures and other non-text media files) The second is the onload, Indicates that all elements, such as a page containing pictures, are loaded and completed.
A lot of people with JQ start writing scripts like this:
$ (function () {//Do something}); In fact this is the shorthand for JQ ready (), which is equivalent to: 
$ (document). Ready (function () {//do something})//or the following method, the default parameter of Jquer is: "Document"; 
$ (). Ready (function () {//do something}) This is the JQ ready () method is Dom ready, his role or significance is that the DOM after the completion of the DOM can be manipulated. In general, the first page response load order is: Domain name resolution-load html-load js and css-loading pictures and other information. Dom ready should be able to manipulate the DOM between "load JS and css" and "load pictures and other information".

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.