Home > Web Front-end > JS Tutorial > How to get modified value in JavaScript

How to get modified value in JavaScript

coldplay.xixi
Release: 2023-01-05 16:13:13
Original
3117 people have browsed it

The method for JavaScript to obtain and modify value is to use the value attribute to modify its value. The code is [var a=document.getElementById("hello");].

How to get modified value in JavaScript

The operating environment of this tutorial: Windows 7 system, JavaScript version 1.8.5, DELL G3 computer.

javascript Get the method of modifying value:

Some elements have value attributes, such as input, bottom, select, etc. You can use the value attribute to modify its value.

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title>修改value</title>
    </head>
    <body>
        <input type="text" name="hello" value="Hello krray" id="hello">
        <script>
            var a=document.getElementById("hello");
            alert( a.value);
            a.value="你好,小凯"
        </script>
    </body>
</html>
Copy after login

Related free learning recommendations: javascript video tutorial

The above is the detailed content of How to get modified value 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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template