jquery check box selection/Cancellation example, when you click the check box to select all the child check boxes, and then click to cancel all check boxes selected state
Function: A: When you click the check box, select all the child check boxes, and then click the check box to cancel all the selected states B: There is a child check box selected, the Parent check box select all the Child check box is not selected, the parent check box does not select the code as follows:/** * full selection function &nb sp;* @param mainid primary check box ID * @param klass subordinate check box class */function SelectAll (mainid,klass) { $ ("." + Klass) . each (function () { if ($ ("#" + Mainid). attr ("checked") = = "Checked") { $ (this). attr ("Checked", "checked"); else{ $ (this) removeattr ("checked"); &NBSP; }); above implementation of the full selection and all the child check box, as for the implementation of the data in the controller received a check box of the array can code as follows:/** * check box has a Select the parent check box to select the <br> child check box does not select the parent check box does not select the ID of the * @param father parent check box * @param son child check box class */function Checksoncheckbox (father,son) { $ ("." +son). Click (function () { if ($ (this). attr ("checked") = = "Checked") { $ (this). AddClass ("checked"); }else{ $ (this). Removeclass ("checked"); } if ($ (".") +son). Hasclass ("checked")) { &Nbsp;$ ("#" +father). attr ("Checked", "checked"); Console.log ("At least one child check box is selected!") "); }else{ $ ("#" +father). Removeattr ("checked");// Console.log ("All child check boxes are not selected!") "); } }; }; Above implement a child check box select the Parent check box select all child check boxes do not select the parent check box is not selected