JQuery reference instance 1.2: after DOM loading is complete, run the jQuery/JavaScript code before page elements are fully loaded.

Source: Internet
Author: User
Mainstream JavaScript applications are required to run JavaScript code only after the DOM is fully loaded. The fact is: Any DOM object traversal or other operations must be performed after the DOM is loaded. Therefore, the application needs to know when the browser fully loads the DOM. If we... SyntaxHighlighter. all ();
Mainstream JavaScript applications are required to run JavaScript code only after the DOM is fully loaded. The fact is: Any DOM object traversal or other operations must be performed after the DOM is loaded. Therefore, the application needs to know when the browser fully loads the DOM. If we use the window. onload event, we must wait for the loading of all page elements-including all images and swf files, and the waiting time is obviously too long. The application requires an event. This event is triggered only when the DOM itself is loaded. Solution jQuery provides a method called ready ()-an event processor typically bound to a document object. The ready () method accepts a function as a parameter. Once the DOM is loaded and can be traversed or other operations, the JavaScript code in the function runs. The following is a simple example. When DOM loading is complete and page elements are not fully loaded, the alert window is displayed.

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.