$(function () {
subtotal();
addorminus();
allcheckbox();
delet();
deleselect();
});
//设置 获取积分和一共金额函数
function countmoney() {
var money = 0; //总金额
var jifen = 0; //总积分
$(".cart_td_7").each(function () {
var m = $(this).text();
money += Number(m);
var j = $(this).siblings(".cart_td_4").text();
var number = $(this).siblings(".cart_td_6").children("input").val();
jifen += Number(j * number);
});
$("#total").html(money);
$("#integral").html(jifen);
}
//小计
function subtotal() {
var obj = $(".cart_td_7");
obj.each(function () { //each遍历每一个clss为.card_td_7的元素
var num = $(this).siblings(".cart_td_6").children("input").val(); //购物车 选中的当前数量
var price = $(this).siblings(".cart_td_5").html(); //当前选中物品的price
var money = num * price; //小计
$(this).html(money);
});
countmoney();
}
//添加或减少数量
function addorminus() {
$(".hand").on("click", function () {
var num;
if ($(this).attr("alt") == "minus") {
num = $(this).next().val();
if (num == 1) {
$(this).css("display", "none");
} else {
$(this).next().val(--num);
}
} else {
num = $(this).prev().val();
$(this).prev().val(++num);
if (num == 1) {
$(this).siblings("[alt==minus]").css("display", "visible");
} else { }
}
subtotal();
});
}
//全选或者全不选
function allcheckbox() {
$("#allCheckBox").live("change", function () {
if ($(this).attr("checked") == "checked") {
$("[name=cartCheckBox]").attr("checked", "checked");
} else {
$("[name=cartCheckBox]").attr("checked", false);
}
});
$("[name=cartCheckBox]").live("change", function () {
var bool = true;
$("[name=cartCheckBox]").each(function () {
if ($(this).attr("cheked") != "checked") {
bool = false;
}
});
if (bool) {
$("#allCheckBox").attr("checked", "checked");
} else {
$("#allCheckBox").attr("checked", false);
}
});
}
//删除
function delet() {
$(".cart_td_8>a").live("click", function () {
$(this).parent().parent().prev().remove();
$(this).parent().parent().remove();
subtotal();
});
}
//删除所选
function deleselect() {
$("#deleteAll>img").live("click", function () {
$("[name=cartCheckBox]").each(function () {
if ($(this).attr("checked") == "checked") {
$(this). parent().parent().prev().remove();
$(this).parent().parent().remove();
}
});
subtotal();
});
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有