当存在多个观测者时,如果希望首先触发最近的观测者则使用冒泡阶段。
When multiple observers are present, use the bubbling phase if you want closer observers to fire first.
如果需要设置事件观测者,应该使用捕获阶段还是冒泡阶段呢?
If you need to set up an event observer, should you use the capture or bubbling phase? Here are a few guidelines.
如果事件抵达目标元素而没有被处理并且该事件类型允许,则进入冒泡阶段。
If the event reaches the target element without being handled and the event type allows it, the bubbling phase begins.
无论使用冒泡阶段还是捕获阶段,默认动作总是在所有的传播完成后执行。
Whether the bubbling or capture phase is used, the default action always happens after all event propagation is finished.
某些事件(如 focus)不参与冒泡阶段,因此只能在捕获阶段观测,或者直接在目标上观测。
Some events like focus do not participate in the bubbling phase, and thus can only be observed during the capture phase or directly at the target.
要记住,对于清单1中onunload所用的HTML 4.0风格的语法,观测者被注册到冒泡阶段。
Keep in mind that the HTML 4.0-style attribute syntax, used for onunload in Listing 1, registers observers for the bubbling phase.
这样就会阻止冒泡阶段事件的继续传播。 阻止捕获阶段的事件传播是不可能的。 有人也许会问为什么。
The event travels upwards again and checks if any ancestor element of the target has an event handler for the bubbling phase.
向下行进到目标称为捕捉(capture)阶段,而再次向上行进称为冒泡(bubbling)阶段(并不是所有的事件都会冒泡)。
The trip down to the target is known as the capture phase, while the trip back up again is known as the bubbling phase. (Not all events can bubble.)
捕获阶段是很少用到的,它也可以是计算密集型。相比之下,冒泡更常见。
The capturing phase is very rarely used, and it can also be computationally intensive. By contrast, bubbling is much more common.
在下个阶段进行之前,你要先确认你所使用的碗和你的手是完全干燥的,否则沐浴弹遇水会起反应冒泡。
For the next stage you need to make sure that the bowl you are using, and your hands, are completely dry - otherwise the bomb will start fizzing.
在下个阶段进行之前,你要先确认你所使用的碗和你的手是完全干燥的,否则沐浴弹遇水会起反应冒泡。
For the next stage you need to make sure that the bowl you are using, and your hands, are completely dry - otherwise the bomb will start fizzing.
应用推荐