This is a basic article. It uses JavaScript to observe the event bubbling mechanism in the Dom and describes how to block default behavior and how to organize event bubbling.
1. The first example can be run in Firefox.
Code highlighting produced by Actipro CodeHighlighter (f
However, in some large web interaction projects today, such as large webgame projects, the influence of JavaScript event bubbling is worth noting. This article uses a simple example to explain the Javascript event bubbling and pre
something, but if the element is added to the onclick, first performance does not say, so many of the code will also make people scoff, which can be used to bubble.Because the triggering of these element events can be bubbling to trigger the events of his father, just add the incident to his father, and then judge exactly what the element's time is triggered. Then you can do whatever you like.Example:Event.target represents the element in which the c
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
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
Block bubbling:Bubble Simple example, the son knew a secret message, it told Dad, Dad knew and told Grandpa, a level of transmission so as to cause the chaos of events, and stop bubbling is not let son tell Dad, Dad naturally won't tell Grandpa. The following demo is a good example. x4812 HTML >34 Head >5 Meta CharSet="UTF-8">6 title > title >7 style type="text/css">8#box9width 300px10Height 300px11background Red12Display None13 14 style >15 Script
Javascript event bubbling1 event
On the browser client application platform, events are basically triggered, that is, an event occurs, and then corresponding actions are taken.
Browser events indicate the signal of some events. The description of the event is not the focus o
1. Event.preventdefault (); --Block The default event for an element.Note: The click of a element to jump to the default event,Default events for form elements such as Button,radio,div element has no default eventCases:href= "http://www.baidu.com" target= "_black"> Baidu a>var samp = Document.getelementbytagname ("a"); Samp.addeventlistener ("click",function (e) {E.preventdefault ()},false);Explanation: Cl
The 1.javascript Dom is nested with each other, and when the child element is clicked, the event is triggered on the child element, and then the event is passed up the level. This is called event bubbling.Event.stoppropagation (); You can stop event
There was a time when the blog has not been updated, 2014 will be over, put a piece of code.Before encountering event bubbling problem, also went to search on the Internet, most of the results are the same code, posted to the time is not very smooth. When it comes to FF, you can use e.stoppropagation (); somehow I didn't succeed. However, I found that FF supports e.cancelbubble = true, and the test is feasi
(i) Event-handling model---event bubbling, capturing(1) Event bubbling - - - - - in - to + - theAs follows: Click on the Blue area, three div will be corresponding Click event(2) Event
The examples in this article describe JavaScript event bubbling. Share to everyone for your reference. The specific analysis is as follows:
Event bubbling:
If element A is nested in element B, then a is clicked not only the OnClick eve
Http://www.aspxhome.com/javascript/skills/200712/262128.htm
That is to say, the mouse event that uses the DIV to frame the flash div is not passed to the body.
Record the methods mentioned in this Article /*---------------------------Function: Stop event bubbling.---------------------------*/ Function Stopbubble
1. Block event bubbling, making it a catch-type event trigger mechanism.1 functionstopbubble (e) {2 //If an event object is provided, this is a non-IE browser3 if(e e.stoppropagation)4 //so it supports the Stoppropagation () method5 e.stoppropagation ();6 Else7 //Otherwise, we need to use IE to cancel the
Simple Mouse Movement Events:
Enter
Copy Code code as follows:
MouseEnter: Not bubbling
MouseOver: Bubbling
The MouseOver event is triggered regardless of whether the mouse pointer crosses the selected element or its child elementsThe MouseEnter event is triggered only when the mouse pointer
Event bubbling: If element A is nested in element B, then a is clicked not only A's OnClick event will be triggered, and the onclick of B will also be triggered. The order of triggering is "from inside Out".
Verify: Add a div, p, strong on the page, add the OnClick event response in Div, p, strong
Can
that if there's an event in there that triggers you, you're going to execute the FN1 function . /*odiv1.addeventlistener (' Click ', Fn1, true); Odiv2.addeventlistener (' Click ', Fn1, true); Odiv3.addeventlistener (' Click ', Fn1, true); Div1->div2->div3*/ //when Clicked Div1, pops up 1; (Div1 bubbles) //when clicking Div2, pop Up 2, 1; (Div2 capture->div1 bubble) //when clicking Div3, pop Up 2, 3, 1; (Div2
This example describes the definition and usage of JavaScript event bubbling. Share to everyone for your reference, specific as follows:
More readers interested in JavaScript-related content can view the site topics: "JavaScript switching effects and tips summary",
The examples in this article describe JavaScript event bubbling. Share to everyone for your reference. The specific analysis is as follows:
Event bubbling:If element A is nested in element B, then a is clicked not only the OnClick event of a is triggered, but also the oncli
1. 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 this handler is not defined or the
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.