1.

What should be the value of “i” so that we get the mentioned result?

Answer»

When an event happens on an element, it first runs on which it was clicked, then on its PARENT, then all the way up on other ancestors. It is the default behaviour of the browser.

Event CAPTURING is the opposite of bubbling and it means when you CLICK on parent element, it GOES till the child.

We will first see Event Bubbling. The HTML contains an parent element containing a child element called Child1. When we click on the “Child1” button, first the console log of child is displayed and then the parent is displayed.

We will now see Event Capturing. The HTML contains an parent element containing a child element called Child1. When we click on the button, first the console log of parent is displayed and then the child is displayed. Notice that in addEventListener we have to pass a value of true.



Discussion

No Comment Found