JS Event Explanation

Source: Internet
Author: User

Three stages of event flow DOM event Flow: 1, Event capture Phase 2, Target Phase 3, event bubbling phase to understand event flow Let's take a look at the entire propagation process of an event: Event Capture phase: User-triggered event window-->document-->html-- >body--> ancestor node-->.......--> parent node and target element event bubbling stage: Target element--parent node-->......-> ancestor node-->body--> Html-->document-->window all browsers implement event bubbling (except Netscape). ie9+ and all modern browsers also support event capture and are captured from window. Note: Because low version ie (ie8-) cannot implement event capture, it is seldom used. The handler for the event handler that responds to an event is the event handler. 1. HTML Event handlers
1 <  type= "button"  value= "click event"  oncick= "Fnhandler ()" />

Note: You can use an entity character instead when you use double quotes, greater than, and less than symbols in an HTML event handler.

1 <Buttononclick= "Fnshow (&quot;hello&quot;)">Click events</Button>2 <Script>3     functionFnshow (SMSG) {4 alert (SMSG);5     }6 </Script>

Disadvantages:

1, time difference problem. When the event handler code is placed after the element, the event handler does not resolve the completion of the user on the departure event will be error;

2, the HTML code and JavaScript code coupling is relatively high.

2, DOM0 class

JS Event Explanation

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.