title: JQuery onChange get previous value
body: <p>Does anyone know how I can retrieve the previous quantity value before it is set in the onChange command here?</p>
  
  <p>I'm currently using this for a input box. The CSS is what's giving me trouble <a href="https://i.stack.imgur.com/Uvj4T.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Uvj4T.png" alt="enter image description here"></a></p>
  
  <p>When I change the value it's easy to set the new quantity and new total cost. However when I press down I can't get it to compare the previous quantity with the new quantity to see if the quantity value has been increased or decreased</p>
  
  <p>The JQuery is below - </p>
  
  <pre><code>$('#p1').on('change', function() { 
          var cost = $('#p1_price').text();
          var quantity = $('#p1').val();
          var total = cost * quantity;
          total = parseFloat(total).toFixed(2)
          $('#p1_total').text(total);
          $('#total_price').text(+$('#total_price').html() + +cost);
      });
  </code></pre>
  
  <p>Can anyone shed some light on the matter. Would be greatly appreciated it! </p>