欢迎来到3672js教程,我们关注js教程、js框架、js代码特效等。

JQ实现购物车全选跟总计全选,

3672Js.Com2019-07-03 12:05 来源:未知 阅读:13726 关注度5

JQ实现购物车全选跟总计全选,


//GoodsCheck购物车每个店铺的checkBox
//goods-check购物车所有的checkBox
//ShopCheck店铺全选的按钮
//commlistFrm店铺商品的模块
//allCheck 所有全选按钮

// 购物车全选
$('.ShopCheck').click(function () {

if ($(this).prop("checked") == true) {
$(this).parents('.commlistFrm').find(".GoodsCheck").prop('checked',true);
}else{
$(this).parents('.commlistFrm').find(".GoodsCheck").prop('checked',false);
}
shopAllcheck();
});


$('.GoodsCheck').click(function () {
shopItemCheck(this);
shopAllcheck();
});

function shopAllcheck() {
var item =$('.mui-content').children('.commlistFrm').find('.GoodsCheck').length;//获取购物车checkbox的数量
var item_check = $('.mui-content').children('.commlistFrm').find('.GoodsCheck:checked').length;
if(item ==item_check){
$('.allCheck').prop('checked',true)
}
else {
$('.allCheck').prop('checked',false)
}
}

function shopItemCheck(t){
var item =$(t).parents('.commlistFrm').find('.GoodsCheck').length;//获取购物车checkbox的数量
var item_check = $(t).parents('.commlistFrm').find('.GoodsCheck:checked').length;
if(item ==item_check){
$(t).parents('.commlistFrm').find(".ShopCheck").prop('checked',true);
}else{
$(t).parents('.commlistFrm').find(".ShopCheck").prop('checked',false);
}
}

// 结算全选
$('.allCheck').click(function () {
if(this.checked==true){
$('.goods-check').prop('checked',true);
}
else {
$('.goods-check').prop('checked',false);
}

});

本站文章为3672js教程网友分享投稿,版权归原作者,欢迎任何形式的转载,但请务必注明出处。同时文章内容如有侵犯了您的权益,请联系我们处理。
相关内容
    暂无相关文章
评论已被关闭
{dede:include filename="foot.htm"/}