Search⌘ K

Solution Review: Event Bubbling

Explore the concept of event bubbling in JavaScript by analyzing how click events on nested elements trigger their event handlers sequentially from the innermost to outer elements. This lesson helps you understand the execution order of event listeners and prepares you for interview questions on event handling.

We'll cover the following...

Question: Solution review #

In the previous lesson you had to figure out the console output of the following code upon clicking the button:

Explanation #

Run the code below to see the output:

From the output, you can tell that Option D is the correct answer. Let’s discuss why.

As you can see, every time you click the button, Button is clicked appears first, followed by Box is clicked. Why is that? ...