I encountered a problem when working on a project today. You need to empty the selected checkbox, and the selected checkbox is not selected. Finally, I found that a method is very good, so I will record it here.
$("input[type='checkbox']").each(function(){if(this.checked){this.checked=false;}});Principle: Loop each type as the input of checkbox. If it is selected, set its checked property to false and it will be OK.
Of course, if you want to achieve the effect of reverse selection, just 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;}});