title: How to add dynamic decimal to another decimal in a div using JQuery
body: <p>I need to be able to add a decimal from input to a decimal in a div. Here's my code below. Right now, it's just concatenating the two number next to each other. Thanks.</p>
  
  <p>EDITED: Working code</p>
  
  <pre><code>&lt;div id="addme"&gt;5.01&lt;/div&gt;
  &lt;input type="text" id="anumber" value=""&gt;
  &lt;button id="add"&gt;Add Number to div&lt;/button&gt;
  
  $('#add').click(function() {
  var number = parseFloat($('#anumber').val()) || 0;
  //alert(number);
  $('#addme').html(function(i, val) {
  return (parseFloat(val) + number).toFixed(2);
  });
  });
  </code></pre>
  
  <p>Old Non-Working Code Below:</p>
  
  <pre><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"&gt;&lt;/script&gt;
  
  &lt;div id="addme"&gt;5.01&lt;/div&gt;
  
  &lt;input type="text" id="anumber" value="" /&gt;
  
  &lt;button id="add"&gt;Add Number to div&lt;/button&gt;
  
  &lt;script type="text/javascript"&gt;
      $('#add').click(function(){
          var number = $('#anumber').val();
          if(number=='undefined' || number==''){
              var number=0;
          }
          //alert(number);
          $('#addme').html(function(i, val) {return val*1+number });
      });
  &lt;/script&gt;
  </code></pre>