Events are one of the core elements of JavaScript, and an important concept that inevitably comes to the application of events is event bubbling, which introduces another important conceptual event flow before introducing event bubbles: A. What is an
also supports text node event bubbling.Event captures reach the top level of the target in different browsers or different browser versions also have a difference. In IE6, HTML is a receive event bubbling, and most browsers continue bubbling to the Window object, which is ... body→documen→window.Blocking bubbles does
However, in today's large web interaction projects, such as large webgame projects, the JavaScript event bubbling effect is worth paying attention to. This article is a simple example of JavaScript event bubbling and usage conside
Example of JavaScript blocking event bubbling, javascript example
Previously, I encountered an event bubble problem and went to the Internet to search for it. Most of the results were the same code, and the post was not very smooth. When FF is involved, you can use e. stopPr
Although proficient in jquery, but not very familiar with its prototype javascript, recently encountered some difficulties in learning javascript, such as bubble and capture, many times mentioned, but I do not know where the application is. I have found some good articles to explain and share them with you.
I. sequence of events
The origin of this problem is very simple. Suppose you have nested another ele
Blocking JavaScript event bubbling transfer (cancelBubble, stopPropagation) cancelBubble is valid in IE
StopPropagation is valid in Firefox
The Code is as follows:
Prevents JavaScript event bubbling transfer (cancelBubble, st
true: Handler placed in capture phase
Just for elem.on(event, selector, handler) , you only need to return false be able to block default events and prevent bubbling
Stop bubbling
It is generally not necessary to block bubbling, since blocking bubbles may affect other
Simple Example of javascript event bubbling, javascript bubble
This article describes the definition and usage of javascript event bubbling. We will share this with you for your referen
= document.queryselector (". Toolbar"); Toolbar.addeventlistener ("Click", Function (e) {var button = E.target; if (!button.classlist.contains ("active")) Button.classList.add ("active"); else Button.classList.remove ("active");});This way we clean up a lot of code and never loop anymore. Note that we used the e.target instead of the previous e.currenttarget. This is because we are listening to events on a different level.
E.target is the object that is currently triggering the
element, let's put the event handling here and try it out. We need to tweak it a little bit:var toolbar = document.queryselector (". Toolbar"); Toolbar.addeventlistener ("Click", Function (e) {var button = E.target; if (!button.classlist.contains ("active")) Button.classList.add ("active"); else Button.classList.remove ("active");});This way we clean up a lot of code and never loop anymore. Note that we used the e.target instead of the previous e.cur
This article mainly introduces JavaScript and jquery mouse mouse event bubbling, this article summarizes some of the findings of the mouse event, and gives the JavaScript and jquery test code, the need for friends can refer to the
Simple Mouse Movement Events:
Enter
The c
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
In JavaScript Dom operation will definitely encounter JS bubbling event, most commonly is the div pop-up window event solutionWhen clicking on the gray part of the pop-up window disappears, clicking on the Black section has no effect.The following section of code to analyze the bub
Cancel Default Action
The method of the consortium is E.preventdefault (), ie is using E.returnvalue = false;
In browsers that support AddEventListener (), you can also cancel the default action for the time by calling the Preventdefault () method of the time object. However, in IE prior to IE9, you can achieve the same effect by setting the ReturnValue property of the event object to False. The following code assumes an
One, what is event bubblingTriggers a class of events (such as clicking the OnClick event) on an object. If this object defines a handler for this event, this event invokes the handler, and if no such event handler is defined or the even
There are very important features in JavaScript events-event bubbling: Gossip Less, let's illustrate everything by observing the following code: If you click on runs The Click event is triggered whenever we click formdiv If we click on P, the browser will execute alert (' P ') in turn; Alert (' div ');Alert (
There are two very important features in the Javasciprt event: event bubbling and the target element.When an event on an element is triggered, such as a mouse click on a button, the same event will be triggered in all ancestor elements of that element. This process is known
=document.getElementById ("Red"); Ogray.onclick=function() {alert ("Click on the gray block! "); } Ored.onclick=function(e) {alert ("Click on the red block! "); varEvent=e||window.event; //block bubbling events, otherwise the Ogray.onclick method will be touched if(document.all) {//IEevent.cancelbubble=true;//This property must be set to TRUE if the event handle wants to prevent the
Let's take a look at a JavaScript event bubbling example. There is a button in the div element, and they are all bound to a click event, which is a precondition for event bubbling. When you click on the button, there will be two w
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.