Introduction to JavaScript event bubbling and Applications' javascript skills

Source: Internet
Author: User
This article helps you understand some of the event bubble knowledge. I. What is event bubbling?
Trigger a certain type of event on an object (such as clicking an onclick event). If this object defines the event handler, this event will call this handler, if the event handler is not defined or the event returns true, the event will be propagated to the parent object of the object, from the inside out, until it is processed (all similar events of the parent object will be activated), or it reaches the top level of the object hierarchy, that is, the document Object (Some browsers are windows ).

For example, if you want to appeal a case in the local court, if the local court does not handle such cases, the local authorities will help you continue to appeal to the higher court, such as from the municipal level to the provincial level, to the Central Court, your case will be handled.

Ii. What is the function of event bubbling?
(1) event bubbling allows multiple operations to be processed in a centralized manner (add the event processor to a parent element to avoid adding the event processor to multiple child elements ), it also allows you to capture events at different levels of the Object layer.

[Centralized processing example]

The Code is as follows:





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.