User Inputs

  • HTML has some elements for user inputs
  • The <input>, <button>, and <select> are probably the most common
  • JavaScript can read the value of inputs
<input type="text" id="my-textbox">
<input type="checkbox" id="my-checkbox">
const myTextbox = document.querySelector("#my-textbox");
const myCheckbox = document.querySelector("#my-checkbox");

const userInputText = myTextbox.value;
const isCheckboxChecked = myCheckbox.checked;

if(isCheckboxChecked) {
    // ...
}

9 / 12