jquery实现购物车的全选与反选


//获取所有的子按钮让下面的去全选按钮跟着改变
var inputs=$('.Item')
var allinput=$('.qxan')
$(".Item").click(function () {
var s = $(".Item").length;
var a = $(".Item:checked").length;
if (s == a) {
allinput.prop('checked', true);
} else {
allinput.prop('checked', false);
}
});

// 点击每一家中的商品或者店名前面的的input框时,让里面额input框也跟着改变  如下图
$('.diangdan').on('tap','input',function(){
if(this.checked){
$(this).parent().parent().siblings().children().children('input').prop("checked",false);
}else {
$(this).parent().parent().siblings().children().children('input').prop("checked", true);
}
})

//点击全选事件
$('.qxan').on('tap',function(){
if(this.checked){
$('.Item').prop("checked",false);
}else {
$('.Item').prop("checked", true);
}

})

 

补充说明:

中间的功能是自己按照实际的需求自己进行修改的

前两个按钮是一家店铺,并在里面所购买一种商品

最后一个为全选按钮

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM