How to get an input text value in JavaScript?

Sometimes, we want to get an input text value in JavaScript.

In this article, we’ll look at how to get an input text value in JavaScript.

How to get an input text value in JavaScript?

To get an input text value in JavaScript, we can use the value property.

For instance, we write

<input type="text" name="enter" class="enter" value="" id="input" />

to add an input.

Then we write

const value = document.getElementById("input").value;

to select the input with getElementById.

Then we get the input’s value with the value property.

Conclusion

To get an input text value in JavaScript, we can use the value property.