How to get a values from <input> tag? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How to get a values from <input> tag?

17th Sep 2019, 7:07 AM
Sandy Harys
Sandy Harys - avatar
2 Answers
+ 3
Usually like this e.g.: let in = document.querySelector("input"); console.log(in.value); Different input types have different values and attributes though. You can find them all on MDN if you want more detailed information :)
17th Sep 2019, 7:10 AM
Aaron Eberhardt
Aaron Eberhardt - avatar
+ 3
You. can assign an id to the input, then do document.getElementById(your id).value to get the value.
17th Sep 2019, 7:59 AM
🍇 Alex Tușinean 💜
🍇 Alex Tușinean 💜 - avatar