Length: 10 minutes
Summary
const myInput = document.querySelector('#my-input');
console.log(myInput.value);
Details
To get the text inside of an input element, first create a variable and select the input.
const myInput = document.querySelector('#my-input');
To get the value, use the variable name followed by a period and then the word value. Here’s an example of grabbing the input value and printing it out to the console.
const myInput = document.querySelector('#my-input');
console.log(myInput.value);
Demo
Exercises
Recreate the JS code from the Demo section in your JS file.