Full selection and anti-election believe in the actual development often used, the following demo a piece of code;
<!DOCTYPE HTML><HTMLLang= "en"><Head> <MetaCharSet= "UTF-8"> <title>JQ simple implementation of full selection and inverse selection</title> <Scriptsrc= "Jquery-3.1.0.js"></Script></Head><Body><DivID= "DV"> <inputtype= "checkbox"/><BR/> <inputtype= "checkbox"/><BR/> <inputtype= "checkbox"/><BR/> <inputtype= "checkbox"/><BR/> <inputtype= "checkbox"/><BR/></Div><HR/><inputtype= "button"ID= "SelectAll"value= "Select All"/><inputtype= "button"ID= "Noselect"value= "All is not selected"/><inputtype= "button"ID= "Select"value= "Reverse Selection"/><Script> //Select All $ ( '#selectAll'). Click (function () { $ ( '#dv >input'). each (function(i, v) {//the parameters of the function can not be passed This. Checked= true;//return false; return false to jump out of the current loop, when the function executes only once } ) } ) //all do not choose $ ( '#noSelect'). Click (function () { $ ( '#dv >input'). each (function(i, v) { This. Checked= false; } ) } ) //Inverse Selection $ ( '#select'). Click (function () { $ ( '#dv >input'). each (function(i, v) { This. Checked= ! This. Checked; //the selected state is now the opposite of the current } ) } )</Script></Body></HTML>
jquery simple implementation of all-select and inverse selection