JavaScript: Add a Click Listener to Log Button Text
Context
Assume your page contains a button element like:
<button id="my-button">Click me</button>
Task
-
Use document.querySelector and addEventListener to add a click handler to the button with id "my-button".
-
When the button is clicked, log the button's text content to the console.
-
Briefly explain what e.target refers to in the click handler.