/**
* 单选
*/
$("#check-box").find("input[name='dict_value']").each(function(){
$(this).click(function(){
// 设置全部取消选中
$("#check-box").find("input[name='dict_value']").each(function(){
this.checked = false;
});
// 当前选中
this.checked = false;
});
});
// js实现
$("#btn1").click(function(){
$("input[name='checkbox']").attr("checked","true");
})
// jquery实现
$("input[type='checkbox']").attr("checked","checked");
// jquery实现
$("input[type='checkbox']").each(function(){
this.checked=true;
});
// js实现
$("#btn2").click(function(){
$("input[name='checkbox']").removeAttr("checked");
})
// jquery实现
$("input[type='checkbox']").each(function(){
this.checked=false;
});
// jquery实现
$("input[type='checkbox']").removeAttr("checked");
});
// 实现一
$("#btn4").click(function(){
$("input[name='checkbox']").each(function(){
if($(this).attr("checked")){
$(this).removeAttr("checked");
}else{
$(this).attr("checked","true");
}
})
})
// 实现二
$(":checkbox").each(function(){
if($(this).prop("checked")){
$(this).prop("checked",false);
}else{
$(this).prop("checked",true);
}
});
// 实现三
$("#invert").click(function(){
$("#ruleMessage [name='delModuleID']:checkbox").each(function(i,o){
$(o).attr("checked",!$(o).attr("checked"));
});
});
$("#btn3").click(function(){
$("input[name='checkbox']:odd").attr("checked","true");
})
$("#btn6").click(function(){
$("input[name='checkbox']:even").attr("checked","true");
})