Indicates whether the given event bubbles up through the DOM or not. "Bubbling" is essentially where an event gets handled first on the element it was assigned to, then subsequently handling the event on that elements parent element, then on that elements parent, and on and on. This process continues until the event reaches an event handler and is therefore "handled." For example, if a button has an event handler on it, and it is clicked, there will be no "bubbling" up through it's parent elements because the event is handled on the button. However, if it is not, the event will "bubble" up, or check the parent element of the button for a handler and on and on until it either finds an event handler or reaches the DOM.
event.bubbles
A Boolean
, which is true
if the event bubbles up through the DOM.
function goInput(e) { // checks bubbles and if (!e.bubbles) { // passes event along if it's not passItOn(e); } // already bubbling doOutput(e) }
Note: 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.
Specification | Status | Comment |
---|---|---|
DOM The definition of 'Event.bubbles' in that specification. | Living Standard | |
Document Object Model (DOM) Level 2 Events Specification The definition of 'Event.bubbles' in that specification. | Obsolete | Initial definition. |
© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/Event/bubbles