title: JQuery multiply input values of table rows
body: <p>I want to calculate each row's total price by multiplying individual row's inputs and then finally calculate a grand total by adding all the total values of the Total column using JQuery. I am only getting the first row to display total when I enter values. Any help will be greatly appreciated.   </p>
  
  <pre><code>     &lt;script type="text/C#" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"&gt;&lt;/script&gt;
      &lt;script type="text/javascript"&gt;
           $(document).ready(function () {
              $(".txtMult").each(function () {
                  $(this).keyup(function () {
                      multInputs();
                  });
              });
             });
  
             function multInputs() {
                 var mult = 0;
                 $(".txtMult").each(function () {
                     var $val1 = $('#val1').val();
                     var $val2 = $('#val2').val();
                     var $total = ($val1 * 1) * ($val2 * 1)
                     $('#multTotal').text($total);
                 });
             }
  
      &lt;/script&gt;
      @using (@Html.BeginForm())
      {
          &lt;table&gt;
          &lt;tr&gt;
              &lt;th&gt;
                  Quanity
              &lt;/th&gt;
              &lt;th&gt;
                  Unit Price
              &lt;/th&gt;
              &lt;th&gt;
                  Total
              &lt;/th&gt;
          &lt;/tr&gt;
          @for (int i=0; i &lt; 5; i++)
          {
  
              &lt;tr&gt;
                  &lt;td&gt;
                      &lt;input class ="txtMult" name="txtEmmail" id="val1"  /&gt;
                  &lt;/td&gt;
                  &lt;td&gt;
                      &lt;input class ="txtMult" name="txtEmmail" id="val2"/&gt;
                  &lt;/td&gt;
                  &lt;td&gt;
                      &lt;span id="multTotal"&gt;0.00&lt;/span&gt;
                  &lt;/td&gt;
              &lt;/tr&gt;
  
      }
  &lt;tr&gt;
      &lt;td colspan="3" align="right"&gt;
          Grand Total# &lt;span id="grandTotal"&gt;0.00&lt;/span&gt;
      &lt;/td&gt;
  &lt;/tr&gt;
      &lt;/table&gt; 
      }
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/sbyZ9.jpg" alt="enter image description here"></p>