--- title: Event.bubbles slug: Web/API/Event/bubbles translation_of: Web/API/Event/bubbles ---
{{ ApiRef("DOM") }}
表示事件是否會向上冒泡傳遞。
var bool = event.bubbles;
回傳一個布林值,若事件會向上冒泡傳遞則回傳 true。
Only certain events can bubble. Events that do bubble have this property set to true. You can use this property to check if an event is allowed to bubble or not.
function goInput(e) {
// checks bubbles and
if (!e.bubbles) {
// passes event along if it's not
passItOn(e);
}
// already bubbling
doOutput(e)
}
| Specification | Status | Comment |
|---|---|---|
| {{SpecName('DOM WHATWG', '#dom-event-bubbles', 'Event.bubbles')}} | {{ Spec2('DOM WHATWG') }} | |
| {{SpecName('DOM4', '#dom-event-bubbles', 'Event.bubbles')}} | {{ Spec2('DOM4') }} | |
| {{SpecName('DOM2 Events', '#Events-Event-canBubble', 'Event.bubbles')}} | {{ Spec2('DOM2 Events') }} | Initial definition. |