title: Multiplication of 2 columns in jQuery
body: <p>I want the multiplication of 2 columns of each row. This is my code and also a script. This script is working but just for the first row the output of this script is: </p>
  
  <p><a href="https://i.stack.imgur.com/p8s7m.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/p8s7m.png" alt="enter image description here"></a> </p>
  
  <p>The result of the 2nd row is wrong:</p>
  
  <pre><code>&lt;form&gt;
  &lt;table id="my-table"&gt;
    &lt;?php
      $query3 = mysqli_query($con,"select * from orders") or die("sdfsfs");
      while($row3=mysqli_fetch_array($query3))
      {
          $quantity = $row3['quantity'];
          $unit_price = $row3['unit_price'];
          //$total = $quantity * $unit_price;
    ?&gt;
          &lt;tr&gt;
             &lt;td&gt;&lt;input type="text" class="common quantity" name="1" id="quant" value="&lt;?php echo $quantity; ?&gt;"&gt;&lt;/td&gt;
             &lt;td&gt;&lt;input type="text" class="common price" name="2" id="units" value="&lt;?php echo $unit_price; ?&gt;"&gt;&lt;/td&gt;
             &lt;td&gt;&lt;input type="text" class="total" name="3" id="total" readonly&gt;&lt;/td&gt;
         &lt;/tr&gt;
   &lt;?php } ?&gt;
          &lt;tr&gt;
             &lt;td colspan="2"&gt;&lt;label class="form-control"&gt;Subtotal&lt;/label&gt;&lt;/td&gt;
             &lt;td&gt;&lt;input name="subtotal" readonly id="subtotal" class="sub"  type="text" /&gt;&lt;/td&gt;
          &lt;/tr&gt;
  &lt;/table&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>jQuery</p>
  
  <pre><code>&lt;script&gt;
          $(".total").each(function() {
          $('.total').val(parseFloat($('#quant').val()) * parseFloat($('#units').val()));
          });
  &lt;/script&gt;
  </code></pre>