Javascript and Events
Making an interactive web page requires a host of events: did users change the status of an element
(e.g. checkbox) or just click it (e.g. a button/div)? Javascript components “listen” for events
to happen and we can bind function to those events to trigger additional functionality.
Learning Objectives
Section titled “Learning Objectives”- Apply HTML, CSS, Markdown, and basic Javascript to develop well-structured, responsive World Wide Web Consortium (W3C) standards-compliant web sites.
- Evaluate and implement web accessibility measures consistent with the Web Content Accessibility Guidelines (WCAG) version 2 specification.
- Design front-end user experiences using accepted web design patterns, methods, and information structures.
The Coding Workbook, “Getting Started with CSS”
The above renders the following:
The previous code triggered an alert, a built-in browser function that creates a pop-over
box containing a message. But, our console contains something much more interesting. To
access your browsers inspect mode Ctrl + Shift + I (or Cmd + Option + I on Mac).
The evt
Section titled “The evt”The evt (short for event) is an object that contains information about the object that
triggered an event (onClick, onChange, et al.). In the above example, we are logging the className
of the source element (i.e. the element producing the event). Here, this allows us to differentiate
which control might have generated an event so that our components can respond appropriately.