为什么输入值未重置1,仍为5?
秒,当我按下ctrl + F5或在url搜索栏中按Enter键时,输入值重置1?
这是我的代码:
var $plus = $('.plus'), //add
$reduce = $('.reduce'), //reduce
$all_sum = $('.sum'); //input
$plus.click(function() {
var $inputVal = $(this).prev('input'),
//input value
$count = parseInt($inputVal.val()) + 1,
$obj = $(this).parents('.amount_box').find('.reduce'),
$priceTotalObj = $(this).parents('.order_lists').find('.sum_price'),
//singlePrice
$price = $(this).parents('.order_lists').find('.price').html(),
//singlePrice*count
$priceTotal = ($count * $price.substring(1)).toFixed(2);
//console.log($price.substring(1));
//数量加运费
$singleTransPrice = $(this).parents('.order_lists').find('.trans_single_price').html(); //单件运费
$transTotalObj = $(this).parents('.order_lists').find('.trans_total_price'); //单件商品总运费
$transTotalPrice = ($count * $singleTransPrice.substring(1)).toFixed(2); //运费
console.log($transTotalPrice)
$inputVal.val($count);
$priceTotalObj.html('¥' + $priceTotal);
$transTotalObj.html('¥' + $transTotalPrice);
if ($inputVal.val() > 1 && $obj.hasClass('reSty')) {
$obj.removeClass('reSty');
}
totalMoney();
});
答案 0 :(得分:1)
尝试<form autocomplete="off" .....>.......</form>
以防止由缓存值填充的表单