Lesson 13 of 18

⚡ Events & Interactivity

🎯 Grades 9–12 ⏱ ~40 minutes 🟡 Intermediate

What You'll Learn

  • addEventListener: click, input, submit, keydown, mouseover
  • The event object: target, value, key, preventDefault()
  • Building interactive UI components: tabs, counters, live filters
Quick Check

1. Which method is the preferred way to attach event handlers?

Ael.onclick = function() {}
Bel.addEventListener("click", fn)
C<button onclick="fn()">

2. Which event fires on every keystroke in an input?

Ainput
Bchange
Ckeypress

3. What does e.preventDefault() do on a form submit event?

ASubmits the form via AJAX
BPrevents the page from reloading when the form submits
CRemoves the form from the DOM

4. e.target in an event callback refers to…

AThe element that triggered the event
BThe parent element
CThe document object