Explain event bubbling and event capturing in javascript?



Explain event bubbling and event capturing in javascript?..

Answer / Sandeep Jaiswal

Event bubbling is the process by which an event cascades up through the DOM tree starting from the element that triggered the event, followed by its parent elements. Event capturing is the opposite, where events cascade down through the DOM tree from the root element to the element that triggered the event.n```javascriptndocument.body.addEventListener('click', function(event) {n console.log('Event captured');n}, true); // Capture phasen document.body.addEventListener('click', function(event) {n console.log('Event bubbled up');n}); // Bubble phasen```

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More JavaScript Interview Questions

20 Functions of Selenium with description and Examples.

1 Answers  


Do you have to declare variables in javascript?

1 Answers  


Why do you need javascript?

1 Answers  


What does double mean in javascript?

1 Answers  


What is a class in javascript?

1 Answers  


Which software is used for javascript?

1 Answers  


What is the use of spread operator?

1 Answers  


Are javascript variables case sensitive?

1 Answers  


How to redirect a page to another page in javascript?

1 Answers  


How to add/remove properties to object dynamically in javascript?

1 Answers  


What do mean by NULL in Javascript?

1 Answers  


How to calculate fibonacci numbers in javascript?

1 Answers  


Categories