Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
582 views
in Technique[技术] by (71.8m points)

stack - When I will write something in textbox1 I want to display the same text in textbox 2 also

I have made two textbox and I will give an ID of text box1 and textbox2 and this is the code - <input type="text" id="textbox1"> <input type="text" id="textbox2"> The problem is when I will write something in textbox1 i want to display it in textbox 2 also


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Try this:

<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body>
<input type="text" id="textbox1" onkeyup="previewText(this.value)" placeholder="">
<br />
<input type="text" id="textbox2" />
<script>
    function previewText(name) {
        document.getElementById("textbox2").value = name;
    }
</script>
</body>
</html>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...