Contact Us

Let us know to help you out quickly!

 Bharat Patel     Feb,08 2017

Check All Checkboxes with JQuery Plugins

A jQuery plugin is simply a way to put your code into a package. It makes it easier to maintain and use in different projects.

I have created sample jquery plugin for checking all checkboxes at one click. Also you can select odd or even row using this plugin. You need to give class of child checkboxes. Remember, Class name must be same for all.

This plugins have three attributes.

1. child - It contains name of class which is assinged to child checkboxes.
2. odd - It contains boolean value either true or false. default value is false;
3. even - It also contains boolean value either true or false. defaule value is false;

Demo Download

jQuery(function(){jQuery('#one').checkall({child : 'child',odd : true});});

jQuery.checkAll.js contains

(function($){$.fn.extend({// Check and uncheck all check boxescheckall: function(options){var defaults = {child : '',odd : false,even : false};var opts = $.extend({},defaults, options);return this.each(function(){obj = $(this);{var checkStatus = $(obj).attr('checked');if(opts.odd == true){$('.'+opts.child+'').attr('checked',false);$('.'+opts.child+':even').attr('checked',checkStatus);}else if(opts.even == true){$('.'+opts.child+'').attr('checked',false);$('.'+opts.child+':odd').attr('checked',checkStatus);}else{$('.'+opts.child+'').attr('checked',checkStatus);}});});}});})(jQuery);