Make the checkbox uncheck the checkbox that is about to be selected
- 2020-03-30 03:32:00
- OfStack
I had a problem today when I was working on a project. You need to leave the checkbox blank. The checkbox you are about to check is not checked. Finally, a method found to work well is hereby recorded.
$("input[type='checkbox']").each(function(){
if(this.checked){
this.checked=false;
}
});
How it works: loop through each input with a checkbox type. If it is checked, set its checked property to false.
Of course, to achieve the effect of anti-selection, add a little more. The code is as follows:
$("input[type='checkbox']").each(function(){
if(this.checked){
this.checked=false;
}
if(!(this.checked)){
this.checked=true;
}
});