![](/img/trans.png)
[英]Automatically display value in a text box based on the value entered in another text box using javascript
[英]How to update the value in one text box based on the value entered in another text box?
如何根據在另一個文本框( txtAmt
)中輸入/更改的值更新一個文本框( txtInterest%
)中的值?
使用jQuery的更改方法進行更新。 使用你的例子:
$('#txtAmt').change(function() {
//get txtAmt value
var txtAmtval = $('#txtAmt').val();
//change txtInterest% value
$('#txtInterest%').val(txtAmtval);
});
另一種實現方法
$(document).ready(function(){
$('#txtAmt').keyup(function (){
$('#txtInterest%').val($('#txtAmt').val())
});
});
假設txtAmt
和txtInterest%
是您網頁上的id
這應該可以正常工作:
$(function() {
$('#txtAmt').change(function() {
$('#txtInterest%').val(this.value);
});
});
請參閱jQuery的change
事件處理程序。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.