Detalation of Event Bubbling and Event Capture Mechanism in JavaScript

Detailed explanation of incident bubbling and event capture mechanism

Describe event trigger timing problem

Event capture

: From Document to the node of the triggering event, you can trigger the event from the top-up to the top of the top

Event bubbling:

Since the bottom-up trigger event — Binding the third parameter of the incident , whether the control event trigger order is incident capture

TRUE , Event capture; false, event bubbling

General default false, ie event bubble

jQuery’s E.Stoppropagation will prevent bubbling, meaning to DOM The ancestral event should not trigger

The following is the example I tried:

  Event bubble and event capture   Window.onLoad = function () {document.getlementByid ("parent"). AddeventListener ("click", function (e) {Alert "Parent event is triggered," +;}, true) Document.getElementByid ("Child"). AddeventListener ("Click", Function (E) {Alert ("Child event triggered," + this.ID )}}}   PARENT event  Child event     
Added a third TRUE, which is the event capture.
If the default event is bubbling, this time the event trigger timing is an inside out
, which is the detailed explanation of the event bubbling and event capture mechanism in JavaScript, such as If you have any questions, please leave a message or to this site community exchange discussion, thank you reading, I hope to help everyone, thank you for your support!
© Copyright Notice
Just support it if you like
comment Grab the couch

Please log in to comment