Reacting to User Input

  • To react to user inputs, HTML elements should trigger JavaScript functions
  • One way to do this is to create a function and reference it in an HTML attribute
  • Remember that JavaScript has two separate steps - Defining a function and calling it
        <button onclick="handleClick()">Click Me</button>
            function handleClick() {
                console.log("Button was clicked")

23 / 24