Elements become objects
A script can select an element and read its text, attributes, classes, or position. Updating those values changes the current document; it does not rewrite the original HTML file on the server.
Events describe what happened
An event begins at a target and can travel through ancestors. A listener receives the event and decides whether to respond. Use the element's native event and behavior when they already match the interaction.
A familiar example
Clearing a search field
- The clear button receives a click event.
- Its handler sets the search value to an empty string.
- The filtered curriculum rerenders and focus returns to the search input.
What to remember
- The DOM represents the current document.
- Events connect user or browser activity to code.
- Prefer native controls before recreating their behavior with generic elements.