复制代码 代码如下:
$(function(){
$(.child_tab 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();
})