您现在的位置: 万盛学电脑网 >> 程序编程 >> 脚本专题 >> javascript >> 正文

jquery实现全选反选功能

作者:佚名    责任编辑:admin    更新时间:2022-06-22

 

 全选功能
$(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'))
})
}
}

})
})