列の合計と行の合計を含むテーブルがあります。誰かが入力フィールドに数値を入力すると、キーアップ時とページ読み込み時に計算されるように設定しました。列はページの読み込み時に再計算されていますが、行はゼロにリセットされています。
// Calculate Sum Of Rows
$(function() {
    $('input').live('keyup', newSum);
    newSum();
});
function newSum() {
    var sum = 0;
    var thisRow = $(this).closest('tr');
    //iterate through each input and add to sum
    $(thisRow).find("input:not(.ignore):not(.description):not(.miles)").each(function() {
            val = parseFloat(this.value);
            sum += isNaN(val) ? 0 : val;   
    });
    //change value of total
    $(thisRow).find(".sumtotalclaimed").html(sum);
}
完全に機能する列のコードは次のとおりです (ページの読み込み時に再計算されます)。
// Calculate Sum Of Columns
$(function() {
    $('input.miles').live('keyup', calculateSum1);  
    calculateSum1();
} );
function calculateSum1() {
    var sum = 0;
    //iterate through each textboxes and add the values
    $("input.miles").each(function() {
        //add only if the value is number
        if(!isNaN(this.value) && this.value.length!=0) {
            sum += parseFloat(this.value);
        }
    });
    //.toFixed() method will roundoff the final sum to 2 decimal places
    $("#summiles").html(sum);
}
newSum(); を置くのと同じくらい簡単だと思いました。関数内ですが、それは機能していません。私が間違っていることはありますか?
ありがとう!