类标记中所有值的总和

I want the Grand Total calculation now.. I want the sum of all the values in the Amount field... I tried tis code but its not working...

$(".amt").each(function(){
    total=total+(parseInt($(this).val()))
});

enter image description here

According to the following HTML:

<table>
    <tr>
        <td><input class="amt" /></td>
    </tr>
    <tr>
        <td><input class="amt" /></td>
    </tr>
</table>
<div id="total"></div>

The JS would be:

$('table').focusout(function() {
    var sum = 0;
    $('.amt').each(function(){
        if (this.value != "") {
            sum += parseFloat(this.value);
        }
    });
    $('#total').html("Grand total: " + sum);
});

JsFiddle

If you are adding these dynamically, you will need to have something like this:

$(document).on('click', '.count', function()
{
    var total = 0;
    $(".amt").each(function()
    {
        total=total+(parseInt($(this).val()))
    });

    alert(total);
});