Using the <text> Element

Value

The value attribute is a string that contains the current value of the text entered into the text field. You can retrieve this using the HTMLInputElement value property in JavaScript.

let theText = myTextInput.value;

If no validation constraints are in place for the input (see Validation for more details), the value may be an empty string ("").