jquery购物车实时结算特效实现思路

时间:2013-09-23    点击:84   
复制代码 代码如下:

$(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(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()是保留小数点的函数很实用哦
}
//初始化
setTotal();

})
基于jquery实现的省市区级联无ajax
JS.elementGetStyle(element, style)应用示例
jquery $.each()使用探讨
jQuery ajax dataType值为text json探索分享
JS 实现导航栏悬停效果
> 返回     
地址:上海市普陀区胶州路941号长久商务中心 电话: QQ:
© Copyright 2012 上海网络 Product All Rights Reserved