Home > Article > Web Front-end > What events cannot bubble up?
The events that cannot bubble are: 1. focus event; 2. blur event; 3. scroll event; 4. mouseenter and mouseleave events; 5. mouseover and mouseout events; 6. mousemove event; 7. keypress Event; 8. beforeunload event; 9. DOMContentLoaded event; 10. cut, copy and paste events, etc.
The operating system for this tutorial: Windows 10 system, DELL G3 computer.
In event bubbling, when an event (such as click, keyboard input, etc.) is triggered on an element, the event will be passed to the parent element of the element, and then to its parent element. The parent element's parent element is passed, and so on, until the outermost element (usually the document object) is reached. This method of event propagation is called bubbling.
However, some events do not bubble up. The following are some events that will not bubble:
1. Focus event: When the user clicks on the text box or input box to gain focus, the bubbling event will not be triggered. The focus event will only be triggered when the user switches to the element via the Tab key or sets the element as focus via script.
2. Blur event: When the text box or input box loses focus, the bubbling event will not be triggered. The blur event will only be triggered when the user leaves the element via the Tab key or removes focus via script.
3. Scroll event: When the user scrolls the page, the bubbling event will not be triggered. The scroll event is only triggered when the page is actually scrolled.
4, mouseenter and mouseleave events: These events are only triggered when the mouse pointer enters/leaves the element and will not bubble.
5, mouseover and mouseout events: Although these events will bubble, they are different from mouseenter and mouseleave because they also trigger on child elements.
6. Mousemove event: When the mouse moves inside the element, the bubbling event will not be triggered. The mousemove event is only triggered when the mouse pointer crosses the boundary of the element.
7. Keypress event: When the user presses a key on the keyboard, the bubbling event will not be triggered. The keypress event is fired only when the key is released and a printable character is produced.
8. beforeunload event: When the window or tab is about to be unloaded, the bubbling event will not be triggered. The beforeunload event is triggered only before the unloading process begins.
9. DOMContentLoaded event: When the HTML document has been fully loaded and parsed and does not wait for the style sheet, images and subframes to complete loading, the bubbling event will not be triggered. The DOMContentLoaded event will only be triggered when the entire document has been loaded.
10. Cut, copy and paste events: These events will not bubble. They only fire when the user performs a cut, copy, or paste operation.
It is important to note that although these events do not bubble up, they can still spread through other means. For example, you can bind an event handler directly to a specific element through the addEventListener() method.
The above is the detailed content of What events cannot bubble up?. For more information, please follow other related articles on the PHP Chinese website!