jquery之全选全不选

2023-02-13,,

<input type="checkbox" onclick="selall(this)" />全选/全不选
<input type="checkbox" class="chk" />选项一
<input type="checkbox" class="chk" />选项二
<input type="checkbox" class="chk" />选项三
<input type="checkbox" class="chk" />选项四
<input type="checkbox" class="chk" />选项午
<input type="checkbox" class="chk" />选项6
<input type="checkbox" class="chk" />选项一
<script type="text/javascript">
function selall(obj)
{
if (obj.checked) {
$(".chk").attr("checked", true);
}
else { $(".chk").attr("checked",false)}
}
</script>

最后提醒一下,别忘了引入jquery。

jquery之全选全不选的相关教程结束。

《jquery之全选全不选.doc》

下载本文的Word格式文档,以方便收藏与打印。