.removeeventlistener (' Click ', box,false);Add events with AddEventListener (what events, what to do, false); False seems to be the event bubbling phase corresponding to the true event capture phase, generally I do not use the rookie of the true, have not tried, anyway write falseDelete event with RemoveEventListener (what event, what to do, false);PS: Add event and delete event, must and add the same time
AddEventListener Event Method One, the event function call syntax:Element.addeventlistener (event, function, usecapture)
Parameters
Describe
Event
Have to. A string that specifies the event name.Note: do not use the "on" prefix. For example, use "click" instead of "onclick".
function
Have to. Specifies the function to execute when the event is triggered.When the event object is passed into t
function 2}Four: From the JS instance view event monitoring see: http://imethan.com/?p=208Five: From the example of JS event Monitoring Learning Notes (event monitoring bindings, ff/ie different processing mechanisms for compatibility summary) See: http://hi.baidu.com/dou917/blog/item/40219f37e6e3deee1b4cff67.htmlSixth: Code Summary
The onclick notation is a DOM0-level specification, which is really supported by all browsers, but there are some drawbacks to this notation:
Object name. AddEventListener ("event name (without on)", function name, true/false);(ff)
Object name. attachevent ("event name", function name);(IE)
Description
Event name, note that "onclick" to Change to "click", "onblur" to "blur", that is, the event name does not take "on".
Function name, remember not to have the last argument with parentheses is a Boolean value that represents the order of response for the event, and the following is an emphasis
The AddEventListener parameters are as followsAddEventListener (Type, listener[, Usecapture]);
Type, event name
Listener, event handler
Usecapture, whether to capture
Always remember that listener is a response function, type of functions. I believe a lot of people understand that too. Most of the time this is usedElem.addeventlistener (' click ', function (EV) {//Todo}, False);The fir
1, Eleobj.addeventlistener (eventname,handle,usecapture);Eleobj:dom elements;EventName: Event name. Note that the event name here does not have "on", such as mouse click event DoubleClick, mouse double click event, mouse move into event mouseover, mouse move out event mouseout, etc.Handle: Event handle function, which is the function used to handle the event;Usecapture:boolean type, whether to use capture, generally with false;2, Eleobj.attachevent (E
The third parameter in addeventlistener is usecapture, A bool type. If it is false, it is obtained by bubbling (from the inside out), and true is the capture method (from the outside to the inside ).
Function addevent (OBJ, SEV, FN ){
If (obj. addeventlistener ){
OBJ. addeventlistner (SEV, FN, false );
} Else {
OBJ. attatchevent ('on' + SEV, FN );
}
}
The thi
Overview: The 3rd parameter, called Usecapture, is a Boolean value that is true or false. If it is true that the browser will use capture mode, false is bubbling, only in a certain situation, it is usually false, and it is the case that the target element has an ancestor element (a. ancestor element), and there is the same event response functionHTML fragment DivID= "Div1"style= "background:blue;width:100px; height:100px;"> DivID= "Div2"sty
Javascript usage of attachevent and addeventlistener
The attachevent method attaches other processing events to an event. (Mozilla series not supported) The addeventlistener method is used in the Mozilla series for example: Java code document. getelementbyid ("BTN "). onclick = Method1; document. getelementbyid ("BTN "). onclick = method2; document. getelementbyid ("BTN "). onclick = method3; document. gete
Dom Methods AddEventListener () and RemoveEventListener () are functions that are used to assign and delete events. Both of these methods require three parameters, respectively:The event name (String), the event handler function (function) to fire, the period or phase (Boolean) that specifies the event handler. Dom Event flow (cut from JavaScript advanced programming, lazy painting):The image shows that the captu
This function is a DOM Level3-level method that registers events with the use of:Dom object. AddEventListener ("event name (such as click)", the function that the event executes (which can be an anonymous function or a functional name), False/true (False indicates the Bubbling method, true means the Capture method));Note here that the second parameter does not seem to compile immediately (of course, JS is n
The AddEventListener parameters are as follows:AddEventListener (Type, listener[, Usecapture]);
Type, event name
Listener, event handler
Usecapture, whether to capture
Always remember that listener is a response function, type of functions. I believe a lot of people understand that too. Most of the time this is usedfunction (EV) { // todofalse);The first parameter has no objection,
1, AddEventListenerThis method is used to add an event handle to the specified elementBrowser support is chrome1.0, ie9+, fireFox1.0, opera7.0The method contains three parameters event, function, UsecaptureEvent is specified, no "on" prefix is requiredFunctions executed when the function is triggered by an eventUSECAPTURE Specifies whether the event is executed in the capture or bubbling phase, true indicates that the event is executed during the
The event broadcast in JS is divided into three phases: event capture, event-handling invocation, event bubbling.
1. Event capture: Walk down the DOM tree to the inside of a node
2. Event invocation: An event handler defined on a node (e.g. click Mouseove, etc.)
3. Event bubbling: Move up from this node along the DOM tree. (This will call the parent element's event-handling call, which can be used with s
The DOM event stream consists of three phases: Event capture, target, and event bubbles.
The idea of event capturing is that an event should be received at an earlier time on a node that is never too specific, and the most specific node should finally receive the event.
Event bubbling events are accepted by the most specific elements at the beginning, and then spread to unspecified nodes step by step.
The idea of weak coupling is to separate HTML from
Problem: CORE!!!!! 1. In the above Div, if you click Core, how many alert will be executed? The order of precedence is above?Bubbling is a way of handling the process of binding events to each node in the DOM node tree;Because of the differences between browser software and related organizations, there are three event streams: event bubbling , event capture ,DOM event flow, where DOM event flow has been implemented by all major browsers;T
Attachevent Different from addeventlistener, the browser version is different.
Attachevent Onclick
Addeventlistener method button click
The usage principle of the two is as follows: the priority of the execution can be different. The example below is as follows:AttacheventMethod To attach other processing events to an event. (Mozilla series not supported)
The ad
Element.addeventlistener (event, function, Usecapture)The parameter usecapture is optional. A Boolean value that specifies whether the event is executed during the capture or bubbling phase.Possible values:True-the event handle is executed during the capture phasefalse-false-default. Event handles are executed during the bubbling phaseHttp://www.runoob.com/try/try.php?filename=tryjsref_element_addeventliste
PostMessage defines the window to which this window is being passed a value. This is where the parent window passes a value to the first child window.
The method AddEventListener (type,function,usecapture) can be preceded by elements, document, window, or XMLHttpRequest
Type string, event name, excluding "on", such as Click,mouseover,keydown.
Message//event, OnMessage event occurs every time an update is received.
When it is postmessage, it can be ac
Example
If you click the mouse on the D3, the event flow is this:
The capture phase detects whether an event handler with Usecapture is true at Div1 and, if so, executes the program and then processes the DIV2 again.
Target phase at Div3, found Div3 is the mouse click node, so this is the target phase, if there is an event handler, then execute the program, here regardless of usecapture true or false.
The bubbling phase detects if there is an ev
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.