JQuery learning notes (3) Events in jQuery

Source: Internet
Author: User

. Loading Interaction Between DOM Javascript and HTML is handled by events triggered by user operations on browser pages. JQuery provides rich event processing mechanisms. From the previous blog, we know that the browser loads the DOM tree first. After loading the DOM elements, the browser begins to add events to the elements. Therefore, you must first understand how the browser loads the DOM. In js, the method for loading DOM is through the window. onload method, while the $ (document). ready () method is used in jQuery. The difference between the two methods is: 1. window. onload () starts to execute the DOM event only when all the elements in the webpage are loaded, and $ (document ). the ready () method can be executed after the DOM tree in the webpage is loaded. For example, if we open a website containing many images. the onload () method starts to run only after all the images on the webpage are loaded ). the lready () method is executed only when the DOM tree is loaded. 2. In terms of writing $ (document). ready (function () {}) can be simplified to $ (function (){}.). 2. Now that event binding is complete, we will naturally start to bind the events we need. How should we bind them? Here is a Demo. Let's take a look at the following Html code. Copy the Code <! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">

Related Article

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.