About Lesson
Passing Parameters to Event Handlers
You can pass parameters to event handlers by wrapping the function call within an anonymous function.
Example:
JavaScript
function showMessage(message) {
alert(message);
}
let button = document.querySelector("#paramButton");
button.addEventListener("click", function() {
showMessage("Button clicked with parameter!");
});
This method allows showMessage to receive the message argument when button is clicked.