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.
label
does exactly that
input
defines the type of input being provided; text, email
textarea
is a multiline text field, think comment or message areabutton
allows the user to send or “submit” their data once they have filled out the form.
submit
, reset
, or anything
button that you design the function for with JSfieldset
element is a convenient way to create groups of widgets that share the same purpose for styling and semantic purposes. You can label a fieldset
by including a legend
element just below the opening fieldset
tagHow 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?
event
, evt
, or e
and is automatically passed to event handlers to provide extra features and informationtarget
is always a reference to the element the event occured uponWhat 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.