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