首頁  >  文章  >  web前端  >  jquery購物車即時結算特效實現思維_jquery

jquery購物車即時結算特效實現思維_jquery

WBOY
WBOY原創
2016-05-16 17:21:491068瀏覽
複製程式碼 程式碼如下:

$(function(){
$tr(". :last-child").find("td").css({borderBottom:'none'})
//取得文字方塊物件
var t = $(".amount-input");
//數量增加操作
$(".amount-up").click(function(e){
var c1=parseInt($(this).prev().val());
$(this).prev().val(c1 1);
e.preventDefault()
setTotal();
});
//數量減少操作
$ (".amount-down").click(function(e){
var c1=parseInt($(this).next().val());
if(c1>=1){
$(this).next().val(c1-1);
};
e.preventDefault()
setTotal();
});
function setTotal( ){
//取每個條件的值
var num1=$(".sum1").text();
var num2=$(".sum2").text();
var num3=$(".sum3").text();
var total=0;
var x1=4,x2=10,x3=49;
//遍歷合計件數
t.each(function(index,ele){
total =parseInt($(ele).val());
});
$(".figure").html(total );
//判斷個數滿足哪一個要求
if(totalb2=num1
}else if(total>=x2&&totalb2= num2
}else if(total>=x3){
b2=num3
}
$(".money").html((total*b2).toFixed(2) '元' );//toFixed()是保留小數點的函數很實用哦
}
//初始化
setTotal();

})
陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn