我想知道如何使用 onkeyup 方法将文本框中输入的值显示到标签中。我可以将其显示在文本框中。这就是我到目前为止所做的:
<script>
function multiply(value){
var x;
x= 2*value;
document.getElementById('out2x').value=x;
}
</script>
<body>
<div style="margin:auto; width:300px; background-color:lightblue; padding:5px;">
<label for="">Input</label>
<input type="text" name="" onkeyup="multiply(this.value);">
<br>
<label for="">Result(x2):</label>
<input type="text" id="out2x" name="" readonly>
</div>
</body>
我尝试将 id 'out2x' 设置为标签,但它不起作用。
catspeake
慕娘9325324
相关分类