How to get and modify input text box data using JS

php中世界最好的语言
Release: 2018-05-26 14:26:50
Original
3976 people have browsed it

This time I will show you how to use JS to obtain and modify the input text box data, and what are theprecautions for using JS to obtain and modify the input text box data. The following is a practical case. Let’s take a look. .

1 Introduction

Getting the text box and modifying its content can be achieved using the

getElementById()method.

getElementById()The method can get the HTML tag by the specified id and return it.

Syntax:

##sElement=

document.getElementById(id)

sElement

: Used to receive an object returned by this method.

id

: Used to set the id value that needs to be obtained from the HTML tag.

Second ApplicationGet the text box and modify its content

It will be displayed in the text box after the page is loaded "Initial text content", the content in the text box will be changed when the button is clicked.

Three Code

   获取文本框并修改其内容 
Copy after login
I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the PHP Chinese website!

Recommended reading:

How to use React high-order components


How to correctly solve cross-domain problems in Vue projects

The above is the detailed content of How to get and modify input text box data using JS. 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!