Use js code to modify the default value of input

Content: Use js code to modify the default value of the input setting, click the button to modify the default value of the input

code:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script>
        function f() {
            var v1 = document.getElementById("input1");
            v1.value = "123456789"
        }

    </script>
</head>
<body>
<input type="text" value="aaa" id="input1">
<input type="button" value="改文字" onclick="f()">
</body>
</html>

Renderings:

 

 

Guess you like

Origin blog.csdn.net/psjasf1314/article/details/124103989