But I could not make the head and tail of the above statement. Can someone please help me to understand the novice like me so that I can grasp this concept.
Events are handled first by bubbling up, then by trickling down (called the capture phase). Normally these days we just use bubbling and ignore capture.
With the above example HTML code, an event listener on the div will pick up events both for itself and for anything inside of the div.
If both the div and the p have an event handler, clicking on the p triggers the p click handler, then the event moves up the tree to the paragraphs parent and triggers the div click handler.
When an event Stops propagation, that prevents the event from triggering any other potential events.
It can be quite tricky to get your head around all the details of events. This article helps to go through most of the details of bubbling and capturing. https://quirksmode.org/js/events_order.html
You click on the link marked “AlsoALink”. So you’ve clicked on that.
But that link is also inside a div, “d”, so the div spans the area of the page that you clicked on. So in truth, you also clicked on that div, and we need to check and see if there’s any click handlers on that div.
Div d is also spanned by div “a”. So you clicked on div “a” as well. Check that one too.
Div b is also inside div A, but it does not span the area that was clicked, so we dont check that.