簡體   English   中英

如何根據在另一個文本框中輸入的值更新一個文本框中的值?

[英]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())
    });
    });

假設txtAmttxtInterest%是您網頁上的id這應該可以正常工作:

$(function() {
    $('#txtAmt').change(function() {
       $('#txtInterest%').val(this.value);
    });
});

請參閱jQuery的change事件處理程序。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM