qns(quiz): describe how to prevent event bubbling (#375)

* Update en-US.mdx

Added information on how to prevent event bubbling to help with related follow up questions.

* Update en-US.mdx

---------

Co-authored-by: Yangshun Tay <tay.yang.shun@gmail.com>
This commit is contained in:
Anisha Jain 2023-05-16 15:38:28 -07:00 committed by GitHub
parent 9d7ff69cea
commit a4bfcf3814
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -2,4 +2,4 @@
title: Describe event bubbling
---
When an event triggers on a DOM element, it will attempt to handle the event if there is a listener attached, then the event is bubbled up to its parent and the same thing happens. This bubbling occurs up the element's ancestors all the way to the `document`. Event bubbling is the mechanism behind event delegation.
When an event triggers on a DOM element, it will attempt to handle the event if there is a listener attached, then the event is bubbled up to its parent and the same thing happens. This bubbling occurs up the element's ancestors all the way to the `document`. Event bubbling is the mechanism behind event delegation. To prevent event bubbling, you can use `event.stopPropagation()`.