JQuery $ (document). ready () and JavaScript onload events

Source: Internet
Author: User
Tags list of attributes

JQuery $ (document). ready () and JavaScript onload events
JQuery $ (document ). ready () and window. onload according to the ready () method API description http://api.jquery.com/ready/ this method receives a function type parameter ready (handler), the role of the method is: Specify a function to execute when the DOM is fully loaded. that is, when the DOM is loaded, execute the specified method. because only after the document status is ready, page operations are safe. $ (document ). ready () is executed only once when the DOM is ready. in comparison, the load event will wait until the page rendering is complete, that is, when all resources (slice) are fully loaded. $ (window ). load (function (){...}) It will wait for the entire page, not just DOM, but also images and iframes to be ready before execution. ready () is executed after the DOM is ready, that is, when the DOM tree is established. therefore, ready () is a better time. if you call the ready () method after DOM Initialization is complete, the new handler passed in will be executed immediately. note: The ready () method is called multiple times. The passed handler method will be executed in series (appended ). in JavaScript, window. onload is a method for assigning values, that is, the latter will overwrite the previous one. example: <! DOCTYPE html> <meta charset = "UTF-8">

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.