0
好的...因爲我是JS的新手,所以不知道如何擺脫這個問題。這是我的形式enter image description here通過輸入Jquery計算加/減
我想抓住瓶子的總安全。
總安全 =數量* 500
其工作正常,但是當我在空瓶輸入數的計算不符合。應當減去總安全量(空瓶子)。我無法做到這一點..
這是我的代碼;
(function() {
$('input[name="quantity"]').bind("focus blur change keyup", function()
$('input[name="total_amount"]').val($(this).val() * $("#pricevalue").val());
$('input[name="total_security"]').val($(this).val() * 500);
});
})();
The above code is working fine... code below is creating the problem
(function() {
$('input[name="empty_bottles"]').bind("on keyup", function() {
var value = $(this).val() * 500;
var test = $("#total_security").val() - value;
$("#total_security").val(test);
});
})();
在此先感謝
您不適合是什麼意思? – error404
第一次減去值,但當我退格並輸入新值時,它從它最後一個值中減去。沒有得到應該是數量* 500的值。 – Coffee
當一半人失蹤時很難遵循邏輯。你可以編輯問題,包括HTML和JS –