Attaching Events to Elements
- Event "listeners" are attached to either an HTML element or the document / window
- One way to listen for events is adding an onEVENT attribute
- (Swap out EVENT with the name of the event you want to watch)
- As the attribute value, call a JavaScript function
<button onclick="doSomething()">
<script>
function doSomething() {
// ...
}
</script>
12 / 17