欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

jquery購物車實(shí)時(shí)結(jié)算特效實(shí)現(xiàn)思路

 更新時(shí)間:2013年09月23日 11:37:50   作者:  
購物車是可以實(shí)時(shí)結(jié)算,下面為大家解釋下通過jquery是如何實(shí)現(xiàn)的,感興趣的朋友可以了解下
復(fù)制代碼 代碼如下:

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

})

相關(guān)文章

最新評(píng)論