全选功能
$(function () {
$('#allchecked').click(function () {
if ($('#allchecked:checked')) {
$('td input').attr('checked', true);
}
if (!$('#allchecked').attr('checked')) {
$('td input').attr('checked', false);
}
})
反选功能
$('#Checkbox8').click(function () {
if ($('#Checkbox8').attr('checked')) {
if ($('td input').attr('checked'))//选中的
{
var bufen = $('td input').each(function () {
$(this).attr('checked', !$(this).attr('checked'))
})
}
}
})
})
本文介绍了一种使用jQuery实现表格中复选框全选和反选功能的方法。通过监听特定按钮点击事件来切换所有复选框的状态,提供了一个简单易用的交互体验。
2390

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



