title: Jquery Dynamic Sum of Inputs with same class
body: <p>I have written the following script. The first part multiplies the quantity and cost per item in a row, and adds it as the value in the ".price" input.</p>
  
  <p>The second part I am attempting to dynamically update the #total value as each .price is added.  But I can't get this part to work. </p>
  
  <pre><code>var total; 
  $('.invoice').on('focus','.current' , function(){
      // Calculate Price
      $('.qty').keyup(function(){
          var qty = $( document.activeElement ).val();
          var value = $( document.activeElement ).siblings(".cost").val();
          $( document.activeElement ).siblings(".price").val(qty * value);
      });
      // Calculate Total
      $('.price').change(function(){
             $('.price').each(function(){
                price = $('.price').val();
                total = parseInt(total) || 0 + parseInt(price) || 0;
                $('#total').val(total);
             });
      });
  });
  </code></pre>