jquery表单输入数量自动计算结果并显示到页面,常用于一些费率计算场景
html代码:
<p style="padding-left: 30px;padding-top: 13px;"><div class="money_rmb" style="margin-left: 20px;color: red;font-size: 14px;font-weight: 600;"></div></p>
表单代码:
<input type="text" name="amount" id="amount" value="" placeholder="提示文字" oninput="amount_input()" >
js代码:
var usdt_rate = "{$fee}";
var cur_amount = null;
var submit_amount = null;
function amount_input(){
cur_amount = $('#amount').val();
if(cu_amount>0){
submit_amount = cur_amount-cur_amount*usdt_rate/100;
$('.money_rmb').html('实际到账:'+submit_amount+' 元');
}else{
$('.money_rmb').html("");
}
}