jQuery实现复选框的全选和反选

作者:袖梨 2022-06-25
代码如下 复制代码

Document

苹果

香蕉

橘子

// 全选

function allPick() {

$("[type=checkbox]:checkbox").each(function () {

this.checked = true;

})

}

// 全不选

function unAllPick() {

$("[type=checkbox]:checkbox").each(function () {

this.checked = false;

})

}

// 反转

function inverserPick() {

$("[type=checkbox]:checkbox").each(function () {

this.checked = !this.checked;

})

}

相关文章

精彩推荐