以下功能僅獲取第一個索引金額,而我需要金額的所有欄位,并在這些欄位中查找金額型別
$("#payment_info").on("change", ".price", function() {
var amount = $(".amount").val();
var price = $(this).val();
var at = $(".amount_type").val();
if (at === "Percentage"){
$('.amount').val(amount * 100 / price);
}
console.log("hello",price,amount, at);
}
);
#payment_info
.card.mt-3
.card-header
h5 Payment Information
.card-body
.row
-if company.id == 11
.col-md-3
= f.input :monthly_rent, label: 'Monthly Rent', input_html: { class: 'maskme', value: "#{contract.monthly_rent unless contract.nil?}" }
.col-sm-3
-if contract.new_record?
= f.input :price, label:'Total Rent', required:true, input_html:{class:'maskme',class:"price", value: "#{unit.market_rent unless unit.nil?}"}
-else
= f.input :price, label:'Total Rent', required:true, input_html:{class:'maskme',class:"price", value: "#{contract.price unless contract.nil?}"}
.col-sm-3
amount_input 和 amount_type 輸入
.atype.col
= f.input :amount_type ,as: :hidden , input_html:{class:"amount_type"}
= f.input :amount,label: f.index == 0 ? 'Amount' : false, placeholder: 'Amount', disabled: disable, input_html:{class:'amount maskme',class:"amount"}
uj5u.com熱心網友回復:
您可以document.getElementsByClassName()
獲取所有元素并對其應用回圈。
var items = document.getElementsByClassName(className);
for (var i=0; i < items.length; i ) {
items[i].val(amount * 100 / price);
}
我希望這能幫到您。
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/508367.html
標籤:javascript jQuery 轨道上的红宝石 红宝石
下一篇:為什么在這種情況下使用引數語法運算子“[”?AsLike""['i']""我用作RGSS、RPGMakerXP和win32api和ruby?