jquery实现购物车非复选框总金额的变化
2017-03-14 22:23
155 查看
<script>
//支付方式
$(".object").on("click",".object-item-img",function(){
$(this).toggleClass("select");
GetCount();
});
//价格结算
function GetCount() {
var conts = 0;
var aa = 0;
$(".object-item .object-item-img").each(function () {
if ($(this).hasClass('select')) {
for (var i = 0; i < $(this).length; i++) {
conts += parseInt($(this).siblings('.object-information').find('p').children('i').text());
aa += 1;
}
}
});
$(".group-title").children(".fr").children("span").html((conts).toFixed(2));
}
$(function () {
var t = $(".numOne");
var num = t.parent('.add-num').siblings('p').children('i').html();
//加号
t.prev('.add').click(function () {
t.val(parseInt(t.val()) + 1)
setTotal(); GetCount();
})
//减号
t.next('.min').click(function () {
t.val(parseInt(t.val()) - 1);
if(t.val() <= 0) {
t.val(0);
}
setTotal(); GetCount();
})
function setTotal() {
t.parent('.add-num').siblings('p').children('i').html((parseInt(t.val()) * parseInt(num)).toFixed(2));
}
setTotal();
});
$(function () {
var t = $(".numTwo");
var num = t.parent('.add-num').siblings('p').children('i').html();
t.prev('.add').click(function () {
t.val(parseInt(t.val()) + 1)
setTotal(); GetCount();
})
t.next('.min').click(function () {
t.val(parseInt(t.val()) - 1);
if(t.val() <= 0) {
t.val(0);
}
setTotal(); GetCount();
})
function setTotal() {
t.parent('.add-num').siblings('p').children('i').html((parseInt(t.val()) * parseInt(num)).toFixed(2));
}
setTotal();
})
$(function () {
var t = $(".numThree");
var num = t.parent('.add-num').siblings('p').children('i').html();
t.prev('.add').click(function () {
t.val(parseInt(t.val()) + 1)
setTotal(); GetCount();
})
t.next('.min').click(function () {
t.val(parseInt(t.val()) - 1);
if(t.val() <= 0) {
t.val(0);
}
setTotal(); GetCount();
})
function setTotal() {
// var price = parseInt(t.val()) * parseInt(num);
// t.parent('.add-num').parent(".object-information").siblings(".object-item-img").html(price);
t.parent('.add-num').siblings('p').children('i').html((parseInt(t.val()) * parseInt(num)).toFixed(2));
}
setTotal();
})
</script>
//支付方式
$(".object").on("click",".object-item-img",function(){
$(this).toggleClass("select");
GetCount();
});
//价格结算
function GetCount() {
var conts = 0;
var aa = 0;
$(".object-item .object-item-img").each(function () {
if ($(this).hasClass('select')) {
for (var i = 0; i < $(this).length; i++) {
conts += parseInt($(this).siblings('.object-information').find('p').children('i').text());
aa += 1;
}
}
});
$(".group-title").children(".fr").children("span").html((conts).toFixed(2));
}
$(function () {
var t = $(".numOne");
var num = t.parent('.add-num').siblings('p').children('i').html();
//加号
t.prev('.add').click(function () {
t.val(parseInt(t.val()) + 1)
setTotal(); GetCount();
})
//减号
t.next('.min').click(function () {
t.val(parseInt(t.val()) - 1);
if(t.val() <= 0) {
t.val(0);
}
setTotal(); GetCount();
})
function setTotal() {
t.parent('.add-num').siblings('p').children('i').html((parseInt(t.val()) * parseInt(num)).toFixed(2));
}
setTotal();
});
$(function () {
var t = $(".numTwo");
var num = t.parent('.add-num').siblings('p').children('i').html();
t.prev('.add').click(function () {
t.val(parseInt(t.val()) + 1)
setTotal(); GetCount();
})
t.next('.min').click(function () {
t.val(parseInt(t.val()) - 1);
if(t.val() <= 0) {
t.val(0);
}
setTotal(); GetCount();
})
function setTotal() {
t.parent('.add-num').siblings('p').children('i').html((parseInt(t.val()) * parseInt(num)).toFixed(2));
}
setTotal();
})
$(function () {
var t = $(".numThree");
var num = t.parent('.add-num').siblings('p').children('i').html();
t.prev('.add').click(function () {
t.val(parseInt(t.val()) + 1)
setTotal(); GetCount();
})
t.next('.min').click(function () {
t.val(parseInt(t.val()) - 1);
if(t.val() <= 0) {
t.val(0);
}
setTotal(); GetCount();
})
function setTotal() {
// var price = parseInt(t.val()) * parseInt(num);
// t.parent('.add-num').parent(".object-information").siblings(".object-item-img").html(price);
t.parent('.add-num').siblings('p').children('i').html((parseInt(t.val()) * parseInt(num)).toFixed(2));
}
setTotal();
})
</script>
相关文章推荐
- jquery实现购物车复选框总金额的变化以及全选和反选
- 利用jQuery实现购物车自动计算总金额
- jQuery实现购物车全选,取消全选,总金额的计算
- jquery实现 购物车 信息 级联改变
- 用jquery实现复选框checkbox的全选
- 基于JQuery实现的类似购物商城的购物车
- 使用JQuery 实现类似购物商城的购物车
- jquery边学边练1--用ul li实现单选框和复选框功能
- jquery 实现框的大小变化
- jquery复选框checkbox实现删除
- jquery复选框checkbox实现删除
- JQuery 实现复选框 多选,反选
- jquery.alert 弹出式复选框实现代码
- 天易20----jquery实现复选框的全选与全不选功能
- 用jquery实现复选框主从选择
- jquery 实现分页绑定复选框选中状态(Repeater控件)
- Jquery练手 DEMO 全选 取消 反选 复选框 的实现
- jquery 操作单选框,复选框,下拉列表实现代码
- jQuery实现点击复选框即高亮显示选中行 全选、反选
- jQuery实现点击复选框即高亮显示选中行 全选、反选