check all related checkboxes - Free Download Check All Related Checkboxes - jQuery jCheckBox

Free Download Check All Related Checkboxes – jQuery jCheckBox

Posted on

This time I will share jQuery Plugin and tutorial about Check All Related Checkboxes – jQuery jCheckBox, hope it will help you in programming stack.

check all related checkboxes - Free Download Check All Related Checkboxes - jQuery jCheckBox
File Size: 63.8 KB
Views Total: 579
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
   

Just another jQuery based Check All plugin that enables a parent checkbox to check and uncheck all of its related checkboxes.

The parent checkbox becomes checked if at least one of its related checkboxes is checked.

How to use it:

1. Include the minified version of the jCheckBox plugin after jQuery library.

1 <script src="/path/to/cdn/jquery.min.js"></script>
2 <script src="/path/to/dist/jquery.jCheckBox.min.js"></script>

2. Create a ‘Parent’ checkbox for checkbox groups as follows:

01 <div class="languages">
02   <div class="parent">
03     <input type="checkbox" id="1" value="1">
04     <label for="1">Manage Student</label>
05   </div>
06   <div class="child">
07     <input type="checkbox" id="2" value="2" class="parent-1">
08     <label for="2">JavaScript</label>
09   </div>
10   <div class="child">
11     <input type="checkbox" id="3" value="3" class="parent-1">
12     <label for="3">XML/HTML5</label>
13   </div>
14   <div class="child">
15     <input type="checkbox" id="4" value="4" class="parent-1">
16     <label for="3">CSS/CSS3</label>
17   </div>
18 </div>

3. Attach the function jCheckBox to the top container. That’s it.

1 let instance = $("#languages").jCheckBox();

4. Check/uncheck all checkboxes programmatically.

1 instance.checkAll();
2 instance.unCheckAll();

5. Uncheck a specified checkbox .

1 // instance.unCheck(id);
2 instance.unCheck(#2);

6. Disable the Check All checkbox.

1 let instance = $("#languages").jCheckBox({
2     checkChildren: false
3 });

7. Override the default CSS selector of the Check All checkbox. Default: ‘parent’.

1 let instance = $("#languages").jCheckBox({
2     parentClass: "customParent"
3 });

8. Available callback functions.

01 let instance = $("#languages").jCheckBox({
02     onParentChecked: function() {
03       // do something
04     },
05     onChildChecked: function() {
06       // do something
07     },
08     onParentUnchecked: function() {
09       // do something
10     },
11     onChildUnchecked: function() {
12       // do something
13     },
14 });

Changelog:

2020-02-25

  • Bugfix

This awesome jQuery plugin is developed by james-muriithi. For more Advanced Usages, please check the demo page or visit the official website.

source : jquery.net