title: Javascript - returning concatenates instead of sum of variables from input
body: <p>I am trying to get values from input field using <code>.each()</code> and adding them to show the sum in another input value. But unfortunately in spite of using parseInt() I am unable to get sum.</p>
  
  <p><strong>HTML</strong></p>
  
  <pre><code>&lt;input type=text name=value[] id=value class="value"&gt;
  &lt;input type=text name=value[] id=value class="value"&gt;
  &lt;input type=text name=totalvalue id=totalvalue&gt;  
  </code></pre>
  
  <p><strong>JavaScript</strong></p>
  
  <pre><code>var totalvalue = parseInt(0);
  $(document).on("focusout",".value",function() {
      $(".value").each(function() {
          totalvalue = parseInt(totalvalue + $(this).val());
      });
      $("#totalvalue").val(totalvalue);
  });
  </code></pre>
  
  <p><a href="http://jsfiddle.net/pr4n8b2u/" rel="nofollow noreferrer">JSFiddle Demo</a></p>