Why some events don't bubble in javascript? need example

I'm currently learning Browser events, and find many events bubble. I can't understand why other events don't do bubble, How to know if event bubbles?

»Javascript @alshakul



» 2 answers  » 91 views   


Add photos



Gadrawin • 2 months ago
When we say some events can't bubble, Its because their travelling journey ends that time it reached target phase. To make things clear, Each event will return a boolean value(true or false) which indicates that event do bubble or not. If event do bubble, it directs an event to its intended target. * if event is handler is set for that object, The event is triggered. These events do not bubble according to what I read on MDN DOCS
  • load
  • unload
  • loadend
  • unload
  • focus
  • blur
  • progress
  • loadstart
  • abort
  • abort
  • error
  • DOMNodeRemovedFromDocument
  • DOMNodeInsertedIntoDocument
  • DOMFocusIn
  • DOMFocusOut
  • mouseenter
  • mouseleave
 »

0  Dislike  •  Reply


Themeeky • 2 months ago
As I can understand this word "Bubbling" means events "bubble" from the inner element up through parents like a bubble in the water. In javascript, almost all events bubble, which means many can bubble, but there are still other events don't bubble such as: focus, load, scroll, reset, unload, loadstart, progress, loadent, etc. Why don't these events bubble? * If the event doesn't do bubble, That means it won't be listened to, while we are in bubbling phase of that event flow but we it can be listened to, capturing that phase of event flow. *It's because any event specific to one element do not bubble.
Simple example: Can bubble <div onclick="alert('division')">DIVISION <p onclick="alert('paragraph')">PARAGRAPH</p> <span onclick=alert('span')>SPAN</span>
As you can see if you click on span it bubbles from the inner element to upper, like a bubble in water »

0  Dislike  •  Reply



Back to top

[SHARE THIS POST]: The post's archived Spread it to others!

Posted under this donnektish »
This community is about sharing contents such as questions and answers discussing about Javascript and TypeScript, ES5, ES6
62 people joined this donnektish



Maintain social distancing, to avoid Covid19