jsp中checkbox复选框的个数是依据从数据库中取出值的条数决定的,是Iterator循环遍历出来的.
?
<td class="rd8">
<input type="checkbox" name="selectFlag" id="selectFlag" value="<%=user.getUser_id()%>">
</td>
?
第一种方式:
?
全选
$("#checkAll").click(function() {
if (this.checked) {
$("input[name='selectFlag']:checkbox").each(function() { $(this).attr("checked", true);
})
}
})
取消全选
$("#delCheckAll").click(function() {
if (this.checked) {
$("input[name='selectFlag']:checkbox").each(function() { $(this).attr("checked", false);
})
}
})
?
第二种方式:
$("#checkAll").click(function() {
if (this.checked) {
$("input[name='selectFlag']:checkbox").each(function() {
$(this).attr("checked", true);
})
} else {
$("input[name='selectFlag']:checkbox").each(function() {
$(this).attr("checked", false);
})
}
})
?
