calculate sub total and total jquery
<p>I have a form with fields like invoice Quantity, Unit Price and Sub total. I want to loop through and get sub total of each input field and finally get sum of sub total. How can I do that on JQuery? Thanks.</p>

<p>My code:</p>

<pre><code>$(document).keyup(function(event) {
    var sub_total = 0;
     $("#items .targetfields").each(function() {
         var qty = parseInt($("#quantity").val());
         var rate = parseInt($("#rate").val());
         $(".subtotal").val(qty * rate);
     });
});
</code></pre>
