title: Jquery sum of inputs from table
body: <p>Im trying to get the sum of an input from a table. Currently I have:</p>
  
  <p>HTML:</p>
  
  <pre><code>&lt;tr id='saved1'&gt;
  &lt;td&gt;&lt;input class='qty'/&gt;&lt;/td&gt;
  &lt;td&gt;&lt;input class='price'/&gt;&lt;/td&gt;
  &lt;td&gt;&lt;input class='subtotal'/&gt;&lt;/td&gt;
  &lt;/tr&gt;
  </code></pre>
  
  <p>Jquery:</p>
  
  <pre><code>//COUNT ALL FIELDS
  function calculateSum() {
    $("[id^=saved]").each(function() {
      sum = $(this).parent().parent().find('.qty').val() * $(this).parent().parent().find('.price').val();
    $(this).parent().parent().find('.subtotal').val(sum);
      });
    }
  
  // On change
  $("input").change(calculateSum);
  </code></pre>
  
  <p>Any Ideas?</p>