Checkboxes jQuery Plugin
How do I make an checkboxes jquery plugin?
What is a checkboxes jquery plugin? How do you make a checkboxes jquery plugin? This script and codes were developed by Dang Van Thanh on 13 September 2022, Tuesday.
Checkboxes jQuery Plugin - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Checkboxes jQuery Plugin</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <table class="table"> <thead> <tr> <th><input type="checkbox" class="selectAll" checked /></th> <th>Make</th> <th>Model</th> <th>Year</th> </tr> </thead> <tbody> <tr> <td><input type="checkbox" id="chk01" name="chk01" /></td> <td>Honda</td> <td>Accord</td> <td>2009</td> </tr> <tr> <td><input type="checkbox" id="chk02" name="chk02" /></td> <td>Yamaha</td> <td>Vixion</td> <td>2013</td> </tr> <tr> <td><input type="checkbox" id="chk03" name="chk03" /></td> <td>Audi</td> <td>R8</td> <td>2009</td> </tr> <tr> <td><input type="checkbox" id="chk04" name="chk04" /></td> <td>Toyata</td> <td>Camry</td> <td>2012</td> </tr> <tr> <td><input type="checkbox" id="chk05" name="chk05" /></td> <td>Hyundai</td> <td>Elantra</td> <td>2010</td> </tr> </tbody>
</table> <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script> <script src="js/index.js"></script>
</body>
</html>
Checkboxes jQuery Plugin - Script Codes CSS Codes
.table { border-collapse: collapse; border-spacing: 0; width: 100%;
}
.table th,
.table td { border: 1px solid #aaa; padding: 5px 10px;
}
.table th { text-align: left; background-color: #ccc;
}
Checkboxes jQuery Plugin - Script Codes JS Codes
(function($) { 'use strict'; $.fn.extend({ checkboxes: function(options) { // Default option var defaults = { itemChild: '' }; var option = $.extend(defaults, options); // Checked value function function checkedValue(element, bool) { if (bool) { return element.each(function() { $(this).prop('checked', true); }); } else { return element.each(function() { $(this).prop('checked', false); }); } } // Return checked or unchecked return this.each(function() { var obj = option, $itemAll = $(this), $itemChild = $('input[name^="' + obj.itemChild + '"]'); // Checked all checkbox before parent checked load page if ($itemAll.is(':checked')) { checkedValue($itemChild, true); } // Checked all or unchecked checkbox when parent checkbox checked or unchecked $itemAll.change(function() { var $self = $(this); if ($self.is(':checked')) { checkedValue($itemChild, true); } else { checkedValue($itemChild, false); } }); // Checked parent checkbox when all child checkbox checked $itemChild.change(function() { var flag = true; if (!$itemChild.is(':checked')) { console.log(!$itemChild.is(':checked')); $itemAll.prop('checked', false); } $itemChild.each(function() { var $self = $(this); if (!$self.is(':checked')) { flag = false; return; } }); $itemAll.prop('checked', flag); }); }); } });
})(jQuery);
$(document).ready(function() { $('.selectAll').checkboxes({ itemChild: 'chk' });
});
Developer | Dang Van Thanh |
Username | dangvanthanh |
Uploaded | September 13, 2022 |
Rating | 3 |
Size | 2,405 Kb |
Views | 18,216 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
Typography with Text | 2,587 Kb |
Simple Player MP3 | 4,812 Kb |
Browser Pure CSS3 | 2,439 Kb |
Scale in CSS3 Transform | 2,028 Kb |
CSS3 Multi-Column Module 1 | 2,212 Kb |
Rotate in CSS3 3D Transform | 1,631 Kb |
Pure Car Animation | 2,501 Kb |
CSS Slide Up and Slide Down | 2,419 Kb |
Media Queries Sass Mixin | 1,973 Kb |
Navigation Responsive with Transition | 2,871 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
Mesmerizing octopus | Jllodra | 3,549 Kb |
JavaScript Animation | Rcmeisty | 4,581 Kb |
Gradient-ui-button-mark-fx | Tabspace | 1,881 Kb |
Dribbble Template | ExtremelyGinger | 2,204 Kb |
Comment Jquery | SquishyAndroid | 2,421 Kb |
SCSS Unit Conversion | Jakob-e | 8,210 Kb |
Brent Burns Tribute Page | Nevada48 | 2,569 Kb |
Google Maps API Ground Overlay | Boycetrus | 2,961 Kb |
Css3 only dropdown menu | Riogrande | 2,519 Kb |
A Pen by Mohomed Anees | Mohomedanees | 12,597 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!