title: JQuery sum rows with unique id elements
body: <p>I'm looking for a way to display the sum of all the input elements (quantity and amount) respectively in the last 2 cells of each line.
  Every element in this table has a unique id. Each input element has an id that contains information about the row it appears in :</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var trRows = ['tr2', 'tr3', 'tr4', 'tr5', 'tr6', 'tr7', 'tr8', 'tr9', 'tr10', 'tr11', 'tr12'];
  
  trRows.forEach(function(trRow) {
  
    var $sumQuantity = 0;
    var $sumAmount = 0;
  
    $(this).find('#tr' + trRow + 'input[id *= "qty"]').each(function() {
  
      $sumQuantity += +$(this).text() || 0;
    });
  
    $(this).find('#tr' + trRow + 'input[id *= "amount"]').each(function() {
  
      $sumAmount += +$(this).text() || 0;
    });
  
    $('#sumQtyTR' + trRows, this).html($sumQuantity);
    $('#sumAmountTR' + trRows, this).html($sumAmount);
  
  });</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"&gt;&lt;/script&gt;
  &lt;table&gt;
  
    &lt;tr id='tr2'&gt;
      &lt;td id='td2_65'&gt;&lt;span id='span_i2qty_65'&gt;&lt;input id='input_i2qty_65' class='editbox'&gt;&lt;/span&gt;
      &lt;/td&gt;
      &lt;td id='td2_65'&gt;&lt;span id='span_i2amount_65'&gt;&lt;input id='input_i2amount_65' class='editbox'&gt;&lt;/span&gt;
      &lt;/td&gt;
  
      &lt;td id='td2_66'&gt;&lt;span id='span_i2qty_66'&gt;&lt;input id='input_i2qty_66' class='editbox'&gt;&lt;/span&gt;
      &lt;/td&gt;
      &lt;td id='td2_66'&gt;&lt;span id='span_i2amount_66'&gt;&lt;input id='input_i2amount_66' class='editbox'&gt;&lt;/span&gt;
      &lt;/td&gt;
  
      &lt;td id='sumQtyTR2'&gt;&lt;/td&gt;
      &lt;td id='sumAmountTR2'&gt;&lt;/td&gt;
    &lt;/tr&gt;
  
    &lt;tr id='tr3'&gt;
      &lt;td id='td3_65'&gt;&lt;span id='span_i3qty_65'&gt;&lt;input id='input_i3qty_65' class='editbox'&gt;&lt;/span&gt;
      &lt;/td&gt;
      &lt;td id='td3_65'&gt;&lt;span id='span_i3amount_65'&gt;&lt;input id='input_i3amount_65' class='editbox'&gt;&lt;/span&gt;
      &lt;/td&gt;
  
      &lt;td id='td3_66'&gt;&lt;span id='span_i3qty_66'&gt;&lt;input id='input_i3qty_66' class='editbox'&gt;&lt;/span&gt;
      &lt;/td&gt;
      &lt;td id='td3_66'&gt;&lt;span id='span_i3amount_66'&gt;&lt;input id='input_i3amount_66' class='editbox'&gt;&lt;/span&gt;
      &lt;/td&gt;
  
      &lt;td id='sumQtyTR3'&gt;&lt;/td&gt;
      &lt;td id='sumAmountTR3'&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;!-- More rows --&gt;
  
  &lt;/table&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>I can't figure out why sums are not displayed. Selectors ? Thanks</p>