jQuery CheckBox 全选/全不选 AND 全选/反选
来源:互联网 发布:零售软件排名 编辑:程序博客网 时间:2024/06/07 16:27
$(function() {
$("#checkAll").click(function() {
var flag = $(this).attr("checked");
$("[name=id]:checkbox").each(function() {
$(this).attr("checked", flag);
})
})
})
</script>
<div>
<input id="checkAll" type="checkbox" />全选/全不选
<input type="checkbox" name="id"/>
</div>
-------------------------------------------------------------------------------------------------------
<script type="text/javascript">
$("#checkAll").click(function() {
$("input[name='id']").each(function() {
if ($(this).attr("checked")) {
$(this).removeAttr("checked");
} else {
if($(this).attr("disabled")==false){
$(this).attr("checked", "true");
}
}
})
});
</script>
<div>
<input id="checkAll" type="checkbox" />全选/反选
<input type="checkbox" name="id"/>
</div>