JavaScript - 14

JavaScript - 14: Event Listeners (Click Events)

Add a click event to the button so that when clicked, it changes the text and color of the message below.

✦ JavaScript Editor
â–¶ Live Output

👀 Show Solution
const button = document.getElementById("action-btn");
const message = document.getElementById("message");

button.addEventListener("click", function() {
  message.textContent = "Button was clicked! 🎉";
  message.style.color = "#00ff9d";
});