javascript--event bubbling and event capture

Source: Internet
Author: User

1. Event bubbling

Microsoft has proposed an event flow called event bubbling. Event bubbling can be figuratively likened to putting a stone into the water, and bubbles will come up from the bottom. That is, the event starts from the most inner element and propagates upward until the document object.

So the above example takes place under the concept of event bubbling. The order of the click events should be HTML --

2. Event Capture

Netscape proposes another event stream named event capture in contrast to event bubbling, the event starts from the outermost layer until the most specific element.

In the above example, the order in which the Click event takes place under the concept of event capture should be the page, HTML --

For an example of bubbling:

Html:

<class= "abc"  ID= "box"> click: Demo bubbling </ Div >

Javascript:

function () {var box = document.getElementById (' box '); Box.addeventlistener (function  () {alert (' Lee 'false); // change False to True to demonstrate capture function () {alert (' document 'false); // change False to True to demonstrate capture false);

javascript--event bubbling and event capture

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.