jQuery实现复选框的全选和反选
<form><label for="apple">苹果</label>
<input type="checkbox" name="apple">
<label for="banana">香蕉</label>
<input type="checkbox" name="banana">
<label for="orange">橘子</label>
<input type="checkbox" name="orange">
<input type="button" value="全选">
<input type="button" value="全不选">
<input type="button" value="反转">
</form>
// 全选
function allPick() {
$(":checkbox").each(function() {
this.checked = true;
})
}
// 全不选
function unAllPick() {
$(":checkbox").each(function() {
this.checked = false;
})
}
// 反转
function inverserPick() {
$(":checkbox").each(function() {
this.checked = !this.checked;
})
}
请自觉引用jquery库
页:
[1]