reading-notes

Reading 9

HTML Forms

Your first web form

Why are forms so important in web development?

When designing a form, what are some key things to keep in mind when it comes to user experience?

List 5 form elements and explain their importance.

Learn JS

How would you describe events to a non-technical friend?

When using the addEventListener() method, what 2 arguments will you need to provide?

Describe the event object. Why is the target within the event object useful?

What is the difference between event bubbling and event capturing?

Event bubbling refers to the default behavior in which an event that is triggered on a child element “bubbles up” through its parent elements all the way to the top of the DOM hierarchy, triggering any event listeners that are registered on those elements along the way. In other words, when an event occurs on an element, it is first processed on the target element and then on each ancestor element in the DOM hierarchy, all the way up to the root element.

Event capturing, on the other hand, is the opposite of event bubbling. It refers to the process of capturing an event at the top of the DOM hierarchy and then propagating it down to the target element. In this case, the event is processed on the root element first and then on each descendant element all the way down to the target element.

To visualize the difference between event bubbling and event capturing, imagine a tree-like structure of nested HTML elements. When an event occurs on a specific element within this structure, event capturing would start from the root of the tree and work its way down to the target element, whereas event bubbling would start from the target element and work its way up to the root.

Both event capturing and event bubbling can be used to handle events in JavaScript, and which method you choose will depend on your specific needs. By default, most events use the event bubbling model, but you can use the addEventListener() method’s capture option to enable event capturing if you need it.