title: How to extract an element from id?
body: <p><strong>Question:</strong> How to extract element from id?</p>
  
  <p><strong>HTML :</strong></p>
  
  <pre><code>&lt;div class="product"&gt;
      &lt;p id="price1"&gt;99,00&lt;/p&gt;
  &lt;/div&gt;
  &lt;div class="product"&gt;
      &lt;p id="price2"&gt;101,00&lt;/p&gt;
  &lt;/div&gt;
  &lt;div class="product"&gt;
      &lt;p id="price3"&gt;50,00&lt;/p&gt;
  &lt;/div&gt;
  &lt;div class="product"&gt;
      &lt;p id="price4"&gt;1,99&lt;/p&gt;
  &lt;/div&gt;
  &lt;div class="product"&gt;
      &lt;p id="price5"&gt;2,01&lt;/p&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p><strong>JS :</strong></p>
  
  <pre><code>var sumPrice = 0;
  
  $(".product").click(function() {    
  
      if ( i = 1) sumPrice += parseFloat($( "#price" + i ).text())
      else if ( i = 2) sumPrice += parseFloat($( "#price" + i ).text())
      else if ( i = 3) sumPrice += parseFloat($( "#price" + i ).text())
      else if ( i = 4) sumPrice += parseFloat($( "#price" + i ).text())
      else if ( i = 5) sumPrice += parseFloat($( "#price" + i ).text())
  
      $(".total").val(sumPrice);
  });               
  </code></pre>
  
  <p>I'm trying to get different prices and summarize. Now I add only the first value.</p>
  
  <p><a href="https://jsfiddle.net/2gczfnph/" rel="nofollow">Fiddle</a></p>