📚 › JavaScript: make pages do things
12. Events in the browser
Este artículo se traducirá automáticamente. Por ahora se muestra en inglés.
JavaScript reacts to events such as clicks. addEventListener('click', function) runs your code when the element is clicked. document.querySelector finds an element by its CSS selector.
This is how pages respond to visitors.
Ver ejemplo
const btn = document.querySelector("#go");
btn.addEventListener("click", () => alert("Clicked"));
✍️ Ahora te toca
Print the text Event ready. Use console.log only, the runner has no page.