全选:
反选:
function checkboxall(){
$("input[@type='checkbox']").each(function(){
$(this).attr("checked",true);
});
}反选:
function rcheckboxall(){
$("input[@type='checkbox']").each(function(){
if($(this).attr("checked")){
$(this).attr("checked",false);
}else{
$(this).attr("checked",true);
}
});
}
本文介绍了一个简单的JavaScript函数实现网页中所有复选框的全选及反选功能。通过遍历页面上的所有[@type='checkbox']元素并改变其checked属性来实现这一目的。
973

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



