jQuery购物车全选怎么做
㈠ JS如何实现全选
简单的如下,从后台读取数据的时候为每家店铺的商品单独加类
<!DOCTYPEhtml>
<html>
<head>
<metacharset="UTF-8">
<scriptsrc="https://cdn.bootcss.com/jquery/2.0.0/jquery.js"></script>
<title></title>
</head>
<body>
<div><inputtype="checkbox"class="classA"/>店铺:test1</div>
<div><inputtype="checkbox"name="nameA"/></div>
<div><inputtype="checkbox"name="nameA"/></div>
<div><inputtype="checkbox"name="nameA"/></div>
<div><inputtype="checkbox"name="nameA"/></div>
<div><inputtype="checkbox"name="nameA"/></div>
<div><inputtype="checkbox"class="classB"/>店铺:test2</div>
<div><inputtype="checkbox"name="nameB"/></div>
<div><inputtype="checkbox"name="nameB"/></div>
<div><inputtype="checkbox"name="nameB"/></div>
<div><inputtype="checkbox"name="nameB"/></div>
</body>
<script>
$(function(){
$(".classA").change(function(){
varstatus=$(".classA").prop("checked");
$("input[name='nameA']").attr("checked",status);
})
$(".classB").change(function(){
varstatus=$(".classB").prop("checked");
$("input[name='nameB']").attr("checked",status);
})
})
</script>
</html>
㈡ 怎么用jquery通过点击全选按钮实现全选
HTML代码:
<table>
<tr>
<td><input type="checkbox" name="b">全选</td><td>内容</td>
</tr>
<tr>
<td><input type="checkbox" name="a"></td><td>复选1</td>
</tr>
<tr>
<td><input type="checkbox" name="a"></td><td>复选2</td>
</tr>
<tr>
<td><input type="checkbox" name="a"></td><td>复选3</td>
</tr>
<tr>
<td><input type="checkbox" name="a"></td><td>复选4</td>
</tr>
<tr>
<td><input type="checkbox" name="a"></td><td>复选5</td>
</tr>
<tr>
<td><input type="checkbox" name="a"></td><td>复选6</td>
</table>
JAVASCRIPT代码:
<script>
$("input[name='b']").click(function(){
//判断当前点击的复选框处于什么状态$(this).is(":checked") 返回的是布尔类型
if($(this).is(":checked")){
$("input[name='a']").prop("checked",true);
}else{
$("input[name='a']").prop("checked",false);
}
});
</script>
3
这样就实现了全选和全不选。
㈢ jquery怎么实现全选复选框
$('#checkedAll').click(function(){
if(this.checked){/*对默认抄是否为选中进行判断*/
// $('[name=checkboxt]:checkbox').attr('checked',true);/*checked为true时为默认显示的状态,为true实现全选功能*/
// }else{
/ $('[name=checkboxt]:checkbox').attr('checked',false);/*false为反选即为全部选功能*/
// }
//实现全选全不选的另一种方法
$('[name=checkboxt]:checkbox').attr('checked',this.checked);/*checked为true时为默认显示的状态*/
});
//实现反选功能
$('#checkedRev').click(function(){
$('[name=checkboxt]:checkbox').each(function(){
this.checked=!this.checked;
});
㈣ 怎么用jquery通过点击全选按钮实现全选 全不选
方法/步骤
HTML代码:
<table>
<tr>
<td><input type="checkbox" name="b">全选</td><td>内容</td>
</tr>
<tr>
<td><input type="checkbox" name="a"></td><td>复选1</td>
</tr>
<tr>
<td><input type="checkbox" name="a"></td><td>复选2</td>
</tr>
<tr>
<td><input type="checkbox" name="a"></td><td>复选3</td>
</tr>
<tr>
<td><input type="checkbox" name="a"></td><td>复选4</td>
</tr>
<tr>
<td><input type="checkbox" name="a"></td><td>复选5</td>
</tr>
<tr>
<td><input type="checkbox" name="a"></td><td>复选6</td>
</tr>
</table>
JAVASCRIPT代码:
<script>
$("input[name='b']").click(function(){
//判断当前点击的复选框处于什么状态$(this).is(":checked") 返回的是布尔类型
if($(this).is(":checked")){
$("input[name='a']").prop("checked",true);
}else{
$("input[name='a']").prop("checked",false);
}
});
</script>
3
这样就实现了全选和全不选
㈤ 用jquery怎么实现全选/全不选
<script>
$("#seleall").click(function(){
$(":checkbox").attr("checked",true);
})
$("#selenone").click(function(){
$(":checkbox").attr("checked",false);
})
$("#selere").click(function(){
$(":checkbox").each(function(){
$(this).attr("checked",!$(this).attr("checked"))
});
})
</script>
需要三个复选框。按个按钮
可实现全选专,全不选属,反选
㈥ jQuery中做购物车的共有几件商品怎么做
那得看你查出来的数据是什么样的格式了,比如一种商品有两件,这算是一条数据还是两条数据,如果是一条数据,那么直接统计数据条数就可以了,如果是两条数据,就要去重计算商品数
㈦ 用jquery怎么实现全选与反选
<ulid="list">
<li><label><inputtype="checkbox"value="1">1.时间都去哪儿了</label></li>
<li><label><inputtype="checkbox"value="2">2.海阔天空</label></li>
<li><label><inputtype="checkbox"value="3">3.真的爱你</label></li>
<li><label><inputtype="checkbox"value="4">4.不再犹豫</label></li>
<li><label><inputtype="checkbox"value="5">5.光辉岁月</label></li>
<li><label><inputtype="checkbox"value="6">6.喜欢你</label></li>
</ul>
<inputtype="checkbox"id="all">
<inputtype="button"value="全选"class="btn"id="selectAll">
<inputtype="button"value="全不选"class="btn"id="unSelect">
<inputtype="button"value="反选"class="btn"id="reverse">
<inputtype="button"value="获得选中的所有值"class="btn"id="getValue">
$(function(){
//全选或全不选
$("#all").click(function(){
if(this.checked){
$("#list:checkbox").attr("checked",true);
}else{
$("#list:checkbox").attr("checked",false);
}
});
//全选
$("#selectAll").click(function(){
$("#list:checkbox,#all").attr("checked",true);
});
//全不选
$("#unSelect").click(function(){
$("#list:checkbox,#all").attr("checked",false);
});
//反选
$("#reverse").click(function(){
$("#list:checkbox").each(function(){
$(this).attr("checked",!$(this).attr("checked"));
});
allchk();
});
//设置全选复选框
$("#list:checkbox").click(function(){
allchk();
});
//获取选中选项的值
$("#getValue").click(function(){
varvalArr=newArray;
$("#list:checkbox[checked]").each(function(i){
valArr[i]=$(this).val();
});
varvals=valArr.join(',');
alert(vals);
});
});
functionallchk(){
varchknum=$("#list:checkbox").size();//选项总个数
varchk=0;
$("#list:checkbox").each(function(){
if($(this).attr("checked")==true){
chk++;
}
});
if(chknum==chk){//全选
$("#all").attr("checked",true);
}else{//不全选
$("#all").attr("checked",false);
}
}
㈧ 如何用jQuery实现checkbox全选
全选:
$(":checkbox").attr("checked","checked");
全不选:
$(":checkbox").removeAttr("checked");
反选:
$(":checkbox:checked").removeAttr("checked");
$(":checkbox:not(:checked)").attr("checked","checked");
全手写,没有经过测试。
完整代码如下,测试通过:
<html>
<head>
<title>如何用jQuery实现checkbox全选</title>
<scriptsrc="jquery-1.7.1.min.js"></script>
<scripttype="text/javascript">
//全选,全不选
functionallSelect(){
if($(":checkbox").attr("checked")!="checked"){
$(":checkbox").attr("checked","checked");
}
else{
$(":checkbox").removeAttr("checked");
}
}
//反选
functionotherSelect(){
$(":checkbox").each(function(){
if($(this).attr("checked")=="checked"){
$(this).removeAttr("checked");
}
else{
$(this).attr("checked","checked");
}
});
}
</script>
</head>
<body>
<inputid="Checkbox1"type="checkbox"/>
<inputid="Checkbox2"type="checkbox"/>
<inputid="Checkbox3"type="checkbox"/>
<inputid="Checkbox4"type="checkbox"/>
<inputid="Checkbox5"type="checkbox"/>
<inputid="Button1"type="button"value="全选"onclick="allSelect();"/>
<inputid="Button3"type="button"value="反选"onclick="otherSelect();"/>
</body>
</html>
㈨ jquery怎么实现全选,全不选,删除功能
全选全复不选
$("#cbxAll").click(function(){
if(this.checked){
$("input[name='你的制checkBox组的name']").prop("checked",true);
}
else{
$("input[name='你的checkBox组的name']").prop("checked",false);
}
});
至于删除功能,这个是需要ajax去做了
㈩ 怎样用jquery实现快速的全选全不选,超简单
<labelfor="all">全选<inputid="all"type="checkbox"value=""/></label>
<labelfor="abc1">选择内容1<inputid="abc1"name="abc"type="checkbox"value="1"/></label>
<labelfor="abc2">选择2<inputid="abc2"name="abc"type="checkbox"value="2"/></label>
<labelfor="abc3">选择3<inputid="abc3"name="abc"type="checkbox"value="3"/></label>
<labelfor="abc4">选择4<inputid="abc4"name="abc"type="checkbox"value="4"/></label>
<script>
$(function(){
$("#all").click(function(){
$("input[name=abc]").prop("checked",$(this).prop("checked"));
});
});
</script>