3.3 - JS + HTML Pt. 2
Today's Lesson: 3.3 - JS + HTML Pt. 2
Last class we discovered the ability to manipulate HTML elements using document.getElementById("id")
We can create a handle to an element to make work easier:
let paragraph = document.getElementById("p1");
How about making our code run only when the user clicks a button or enters some data?
Event Listeners allow us to attach code to any HTML element. The element listens for the user to do a particular action known as an event (click, type, mouse hover, etc).
In-class demo can be found here (it's interactive if you want to try something in the code).
Important Notes & Resources:
You can attach multiple event listeners to the same HTML element so that many functions are called or different functions are called based on different actions.