DOM Ready Brief

Source: Internet
Author: User

When the page load is done to do something: in general, the response load order of a page is: Domain name resolution-loading html-loading JS and css-loading pictures and other information.

1.window.onload Events

Effect: Triggers when all the resources on the page have been loaded. A slow response to a resource such as a large picture on the page can cause the Window.onload event to delay the triggering

Principle: One is ready, indicating that the document structure has been loaded (does not contain picture non-text media files).

The second is onload, which indicates that all elements, including pictures and other files, are loaded and completed.

Code:

1 function () {2   // Do something 3   4 }

2.Dom Ready

Effect: When the first step is complete, the DOM ready event is triggered.

Code:

1 The first type: the abbreviation for JQ ready ()2$(function(){3    //Do something4 })5 6 The second type:7$ (document). Ready (function(){8    //Do something9 })Ten  One The third: The default parameter for jquery is: Document A$ (). Ready (function(){ -    //Do something -})

Dom ready and DOM load usage:

Dom ready: After the DOM is loaded, you can directly manipulate the DOM, such as a picture as long as the tag is complete, do not wait for the picture to be loaded, you can set the image width of the properties and styles, etc., you can use the DOM ready.

Dom Load: It is possible to manipulate the DOM directly after loading the entire DOM document (including other information such as loading pictures), such as a picture to be loaded before the image can be set to the width of the property and style.

Reference Document: Http://www.cnblogs.com/zhangziqiu/archive/2011/06/27/DOMReady.html

Http://wenku.baidu.com/link?url= Extgn5g-s7nrxv5ugfy5qjyrwurjp48ysumpgv-hqlctzeudlmi3vdau6t4ux4ycdvtcranjzdsbpwvn4ka9a_8adavlvsagbyvkdre2ogo

DOM Ready Brief

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.