We all know to make forms using HTML. Now, we will learn how to get and store the input from user.
There are multiple methods in JS to do that using the DOM model. Below is the method that is generally taught to students.
Get Element By ID
This is one of the most preferred and widely used method by coders to get input.
See the example below.
var text = document.getElementById('tb').value;
<input type="text" id="tb" placeholder="Enter text">
<button type="button" onclick="demo()">Click</button>
We hope that you found this article to be helpful.
Please share your thoughts in the Comments Section.
If you liked this article, then please like our Facebook page.