页面
<input type="checkbox" name="chkritb" id="chkritb" />
<input type="checkbox" name="chkritb" id="chkritb" />
<input type="checkbox" name="chkritb" id="chkritb" />
<input type="checkbox" name="chkritb" id="chkritb" />
<input type=”checkbox” name=”checkedAll” id=”checkedAll”/>全选/取消全选
<script type="text/javascript">
$(function () {
$("#checkedAll").click(function () {
if ($(this).attr("checked") == true) { // 全选
$("input[id=chkritb]").each(function () {
$(this).attr("checked", true);
});
} else { // 取消全选
$("input[id=chkritb]").each(function () {
$(this).attr("checked", false);
});
}
});
});
</script>
本文介绍了一种使用JavaScript和jQuery实现全选和取消全选功能的方法。通过点击全选按钮,页面上所有指定ID的复选框都会被选中或取消选中,实现了批量操作的功能。
1427

被折叠的 条评论
为什么被折叠?



