Understanding jquery event bubbling and jquery event bubbling

Source: Internet
Author: User

Understanding jquery event bubbling and jquery event bubbling

I. What is jquery event bubbling?
Many textbooks or manuals may involve the concept of event bubbling. For veterans, this is of course the most basic concept, but it may be unfamiliar to beginners or never heard of it. The following describes what event bubbles are based on code instances.
The code example is as follows:

<Html> 

In the above Code, we may just want to click the anchor to bring up "I am third", But the strange thing is that all the click events defined by the parent element will be triggered. This is a typical event bubble effect. The so-called bubble event is that if a type of event (click event in the preceding example) is triggered on an object, the event will be propagated to the parent object of the object, trigger similar events defined on the parent object. The event propagation direction is from the bottom layer to the top layer, similar to water bubbles floating from the bottom.
Ii. How does javascript prevent event bubbling?
Bubble events can bring convenience and sometimes cause troubles. The following describes how to prevent event bubbles.
The code example is as follows:

<! DOCTYPE html> 

Code comment:
1. if (window. event) is used to be compatible with IE 8 and IE 8 browsers.
2. evt. stopPropagation () is a standard browser.

In the above Code, a cell prevents event bubbles, and one does not prevent event bubbles. I hope this will help you learn more.

Articles you may be interested in:
  • Jquery prevents event bubbling event. stopPropagation
  • Introduction to jquery event bubbling and how to prevent event bubbling
  • What is event bubbling? How does jquery block event bubbling?
  • JQuery prevents event bubbles
  • Example of js blocking bubbling and jquery blocking event bubbling
  • Several methods to prevent event bubbling in JQuery and their differences
  • Event bubble usage example of event object e in jQuery
  • JavaScript and JQuery mouse event bubble Processing

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.