Home > Article > Web Front-end > How to get the value entered by the user in javascript
In JavaScript, you can use the value attribute to get the value entered by the user. This attribute can return the value in the input box or text box. The syntax format is "input box or text box object.value;".
The operating environment of this tutorial: windows7 system, javascript version 1.8.5, Dell G3 computer.
var val = document.querySelector("input"); val.value;//获得input输入的值
var val = document.querySelector("textarea"); val.value;//获得textarea输入的值
<select id="city"> <option value="nj">南京</option> <option value="sh">上海</option> <option value="bj">北京</option> </select>
var mySelect=document.querySelector("select#city"); mySelect.value;
More programming related For knowledge, please visit: Introduction to Programming! !
The above is the detailed content of How to get the value entered by the user in javascript. For more information, please follow other related articles on the PHP Chinese website!