title: How to get total price when incrementing or decrementing quantity?
body: <p>I have an issue in this below code. so basically what I want is each time I press on plus or minus button the total price should increase and decrease. the issue is when I console.log sum variable it works fine in the console but when I add the sum variable in the tag it starts multiplying the total amount by the input number.
  <a href="https://i.stack.imgur.com/4Wkyj.png" rel="nofollow noreferrer">this is when I console logged it</a> and <a href="https://i.stack.imgur.com/49PCl.png" rel="nofollow noreferrer">this is when it's on the tag</a></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 increment = document.querySelector('#myform .qtyplus');
  var decrement = document.querySelector('#myform .qtyminus');
  increment.addEventListener('click', incrementValue);
  decrement.addEventListener('click', decrementValue);
  
  function incrementValue() {
    var value = parseInt(document.getElementById('input-number').value);
    if (isNaN(value) || value &lt; 1) {
      value = 1;
    }
    value++;
    document.getElementById('input-number').value = value;
    productpagetotal()
  }
  
  
  function decrementValue() {
    var value = parseInt(document.getElementById('input-number').value);
    if (isNaN(value) || value &lt; 1) {
      value = 1;
    }
    value--;
    document.getElementById('input-number').value = value;
    productpagetotal()
  }
  
  
  function productpagetotal() {
    var sum = 0;
    var producttotal = parseFloat(document.querySelector('.span').innerText.replace('$', ''));
    var quantity = document.getElementById('input-number').value;
    sum = sum + (producttotal * quantity);
    sum = Math.round(sum * 100) / 100;
    producttotal.innerText = sum;
    console.log(sum)
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class="quant"&gt;
    &lt;p&gt;Qty&lt;/p&gt;
    &lt;form id='myform' method='POST' action='#'&gt;
      &lt;input type='button' value='-' class='qtyminus' field='quantity' /&gt;
      &lt;input type='text' id="input-number" name='quantity' value='1' class='qty' /&gt;
      &lt;input type='button' value='+' class='qtyplus' field='quantity' /&gt;
    &lt;/form&gt;
  &lt;/div&gt;
  
  &lt;div id="last-list"&gt;
    &lt;h6 style="font-size: 17px"&gt;Free Shipping on Order over $80&lt;/h6&gt;
    &lt;h4 class="in-h4"&gt;Delivery to pincode 000001 - within 2-4 business days&lt;/h4&gt;
    &lt;div class="total-price"&gt;
      &lt;span&gt;Total Price&lt;/span&gt;
      &lt;span class="span product-total-price"&gt;$24.99&lt;/span&gt;
      &lt;button class="add-to-card"&gt;ADD TO CART&lt;/button&gt;
    &lt;/div&gt;
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>