In-depth study of JavaScript event mechanism

Source: Internet
Author: User
At the beginning of this article, we will review the Javascript event mechanism. At the same time, it will be written from a minimum function to

At the beginning of this article, we will review the Javascript event mechanism. At the same time, it writes from the smallest function to the last powerful event module with complete functions. To facilitate the description, the response function, callback function, event Listener, and event handler are called event handler.

First, let's look at several ways to add events to the page:

  1. Directly write JS Code on HTML
  2. Test: Nowamagic
    Nowamagic

    The HTML Element has many onXXX attributes. You only need to assign values to the JS Code. The string assigned to onXXX is used as the function body of the response function ). Probably this was written in the 1990s S. At that time, it was common to directly write JS Code on webpages. Maybe JavaScript was not very important at that time, but it was just used for verification or some fancy effects.

  3. Define a function and assign it to the onXXX attribute of the html element.
  4.  
    

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.