To implement the selection-related mappings for a multi-box, implement the following logic:
1, the selection box is clicked, so the sub-box is selected.
2, when the whole selection state, the sub-box of one of the undo click, All box automatic unchecked
3, for the full selection of the state, the sub-box selection of all, the last sub-selection box after the click, the entire marquee automatically checked
var information=$ ("#" +flag). Find (". Information"); var $newsCheck = information.find (" Input[name= ' Newscheck ');//Multi box Select all with no $ (". All"). Click (function () { if (this.checked) { $ (this). Parents (). Parents (). Siblings (". Lists"). Find ("Input[name= ' Newscheck ']"). each (function () {this.checked=true;}); }else{ $ (This). Parents (). Parents (). Siblings (". Lists"). Find ("Input[name= ' Newscheck ']"). each (function () {this.checked=false;}); } });//Sub-marquee Select $ ("Input[name= ' NewsCheck ')" ). Click (function () { var temp=document.getelementsbyclassname ("All"); for (var i=0;i<temp.length;i++) { if (Temp[i]. Id == flag+ "All") { temp[i].checked= ($ Newscheck.length ==information.find ("Input[name= ' Newscheck ']:checked"). length ? true : false); } });
<div id= "Informcontent" > <div class= "InformTitle title-blue" > News </div> <div class= "Information" > <div class= "Informmenu" > <div class= "Allcheck" ><input type= "checkbox" class= "All" Id= "Informcontentall" ><span> full selection </span></div> <div class= "Threebutton" ></div > <div class= "AddButton" id= "NEWSPB" ></div> </div> <div class= "Lists" > <div class= "Informlist" > <div class= "Newstitle" ><input type= " CheckBox " name=" Newscheck "> Facebook prise open Apple homekit push IoT cloud Platform <span class= "Newstime" >2015-2-10</span></div> <div class= "Newstitle" ><input type= " CheckBox " name=" Newscheck "> Facebook prise open Apple homekit push IoT cloud Platform <span class= "Newstime" >2015-2-10</span></div> <div class= "Newstitle" >< input type= "checkbox" name= "Newscheck" > Facebook prise open Apple homekit push IoT cloud Platform <span class= "Newstime" >2015-2-10</span></div> </div> </div></div><div id= "Activitycontent" > <div class= " Informtitle title-red "> Activity </div> <div class=" Information "> <div class= "Informmenu" > <div class= "Allcheck" ><input type= "checkbox " class=" All " id=" Activitycontentall "><span> Select all </span></div> <div class= "Threebutton" ></div> <div class= "AddButton" id= "ActivityPB" ></div> </div > <div class= "Lists" > <div class= "Informlist" > <div class= "Newstitle" ><input type= "checkbox" name= "Newscheck" > Facebook prise open Apple homekit push IoT cloud Platform <span class= "Newstime" >2015-2-10</span></div> <div class= "Newstitle" ><input type= "checkbox" name= "Newscheck" > Facebook prise open Apple homekit push IoT cloud Platform <span class= "Newstime" >2015-2-10</span></div> <div class= "NewsTitle" ><input type= "checkbox" name= "Newscheck" > Facebook prise open Apple homekit push IoT cloud Platform <span class= "Newstime" >2015-2-10</span></div> </div> </div> </div></div>
Here I'm going to explain that I've covered two sets of boxes in one page, and the related class names of the two sets of checkboxes are all named the same, so I want to make a generic check style.
$ (". All") represents a Select checkbox for both sets of checkboxes, and the two groups of sub-marquee name are newscheck. The variable flag information is a variable used to differentiate between two sets of multi-marquee boxes. Flag has two values: "Informcontent" and "activitycontent", as to how the specific value is converted depends on each individual's project.
Select all, uncheck and reverse the Multi box