総消費量と一人当たりの消費量を計算してみます。
関連コード:
$(function () {
$(".items").keyup(function (event) {
var total = 0;
$(".items").each(function () {
var gtotal = 0;
$(this).find(".targetfields").each(function () {
var qty = parseInt($(this).find(".quantity").val()||'0');
var rate = parseInt($(this).find(".rate").val()||'0');
var subtotal = qty * rate;
$(this).find(".subtotal").val(subtotal);
if (!isNaN(subtotal)) gtotal += subtotal;
});
$(this).find(".g_total").html(gtotal + "Din");
total += gtotal;
});
$("#total").html(total + "Din");
});
});
テストのフィドル:http://jsfiddle.net/Odisej/CgeHU/
行き詰まります...このスクリプトの何が問題になっていますか?