reading-notes

🗒️ Class 09 Forms and JS Events

HTML Forms

Learn Js

lecture notes

API - Application Programming Interface

DOM = API For HTML elements in JS

inputElement.addEventListener(‘input’, function())

``` javascript // find what element we want to add action/ event to let inputElement = document.getElementById(‘inputElement’); let formElement = document.getElementById(‘formElement’);

// event/action function functionName{ console.log(‘im a function’); }

// attach event to element inputElement.addEventListener(‘input’, functionName)

// browser has some defaults, prevent default submissino behavior so page doesnt reload formElement.addEventListener(‘submit’, function(event){ event.preventDefault(); //dont refresh page });