Pergunta de entrevista da empresa Nagarro

What is Event bubbling?

Respostas da entrevista

Sigiloso

3 de abr. de 2018

I think it's a little bit vague description. Event bubbling is one of the ways of event propagation in HTML DOM API. Event propagation is the method which determines the order, in which nested element receives an event. For eg- Suppose we have two nested divs, Parent and Child. Let's add two methods to both divs click event. <div> <div></div> </div> Whenever we click on the above nested div which function is going to fire first? In event bubbling, child function is fired first then parent method is fired while in an event capturing the parent function is fired first and then child function is fired.

1

Sigiloso

19 de dez. de 2016

Event bubbling directs an event to its intended target, it works like this: A button is clicked and the event is directed to the button. If an event handler is set for that object, the event is triggered. If no event handler is set for that object, the event bubbles up (like a bubble in water) to the objects parent