Does anyone know how I can retrieve the previous quantity value before it is set in the onChange command here?
I'm currently using this for a input box. The CSS is what's giving me trouble
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
The JQuery is below -
$('#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);
});
Can anyone shed some light on the matter. Would be greatly appreciated it!