How to get text box value in JavaScript?

Spread the love

To get text box value in JavaScript, we use the value property.

For instance, we write

<input type="text" name="txtJob" id="txtJob" value="software engineer" />

to add an input.

Then we write

const job = document.getElementById("txtJob").value;

to select the input with getElementById.

And then we get its input value with the value property.

Leave a Reply

Your email address will not be published. Required fields are marked *