我需要传递并将key id =“a”的值设置为keyup时输入id =“b”。有什么想法??
<input id="a" name="a" value="" type="text">
<input id="b" name="b" value="" type="text">
var a = document.getElemntById('a').value
var b = document.getElementById('b').value = $a
答案 0 :(得分:-1)
你可以试试这个..
<!DOCTYPE html>
<html>
<body>
Name: <input type="text" id="myText" >
2nd Name : <input type="text" id="myText2" >
<p>Click the button to change the value of the text field.</p>
<button onclick="myFunction()">Try it</button>
<script>
function myFunction() {
document.getElementById("myText2").value = document.getElementById("myText").value;
}
</script>
</body>
</html>