- Instant help with your JavaScript coding problems

Get the value of text input field in JavaScript

Question:
How to get the value of text input field in JavaScript?
Answer:
const inputValue1 = document.getElementById('input-field-id').value;
Description:

To get the value of an HTML text input element you can use the value property of the element. To get the element you can use the document.getElementById method or if you want a more generic, jQuery-like syntax use the document.querySelector method.

Share "How to get the value of text input field in JavaScript?"