Event bubbling, bubbling stop

As long as there are events, there will be a bubble.

Event bubbling three elements: the event source, event type, handler.

A process has to do something

Event flow in three stages: capture, target, bubbling.

What is the event bubble: On page elements may be stacked one by one, and the bottom is a document file, each layer may be provided with elements event (such as a click event onclick), in order to perform this event, it will be a layers of looking down, and then like a bubble in the water to take up the same reaction.

There is a problem here, if the two elements have overlapping binding events, then click the mouse once will result in two events are triggered, however, you might want to trigger an event which so ...... to prevent misuse, we want to prevent bubbling.

Prevent bubbling:

 e.stopPropagation //非ie

 window.event.cancelBubble=true//ie

 

Guess you like

Origin www.cnblogs.com/qianduanxiaozhang/p/11136006.html