How to get the value entered by the user in javascript

青灯夜游
Release: 2023-01-07 11:46:06
Original
10011 people have browsed it

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;".

How to get the value entered by the user in javascript

The operating environment of this tutorial: windows7 system, javascript version 1.8.5, Dell G3 computer.

Get the value of the input input

var val = document.querySelector("input"); val.value;//获得input输入的值
Copy after login

Get the value of the textarea input

var val = document.querySelector("textarea"); val.value;//获得textarea输入的值
Copy after login

Get the value of the selected drop-down list

Copy after login
var mySelect=document.querySelector("select#city"); mySelect.value;
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!