![](https://i.imgur.com/56C2ubQ.png =200x) # Coaching - Events and Listeners with Founders and Coders --- Last week, we looked at how we can get elements from HTML and how we can alter them in JS. ---- This week, we'll look at how we trigger those changes when a user interacts with a page. --- ## Events ---- In JS, user inputs are known as events. ---- This could be: - a click - moving the mouse over an element - a key being pressed ---- See a list of events [here](https://www.w3schools.com/jsref/dom_obj_event.asp). --- ## Event Listeners ---- We handle events by adding event listeners to elements. ---- ```javascript= const myButton = document.querySelector("button"); const myFunction = (event) => { event.target.textContent = "Clicked" }; myButton.addEventListener("click", myFunction); ```
{"metaMigratedAt":"2023-06-15T22:57:49.406Z","metaMigratedFrom":"YAML","title":"Coaching - Events and Listeners","breaks":true,"slideOptions":"{\"theme\":\"white\"}","contributors":"[{\"id\":\"2967aacf-1990-431e-b963-91e79ce4a2bf\",\"add\":987,\"del\":104}]"}
    136 views
   Owned this note