Complete addEventListener
Fill in the Blank Easy
Question
Fill in the blank to listen for click events on the button.
Code
const btn = document.getElementById("btn");
btn.___("click", () => {
console.log("Clicked!");
});
Hint
Use the method that registers an event handler.
Explanation
addEventListener registers a function to be called when the specified event occurs on the element. btn.addEventListener("click", handler) calls handler every time the button is clicked. This is the standard way to handle DOM events.
Related Resources
Related Lessons
- DOM
Learn about addEventListener.
Look up unfamiliar terms
A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.
Build real projects
Apply what you learned by building guided projects with starter code and solutions.