Created
June 14, 2011 21:30
-
-
Save justinrains/1025948 to your computer and use it in GitHub Desktop.
Checkbox toggle
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* jQuery - toggle checkboxes | |
* June 14, 2011 - Justin Rains | |
* http://www.justinrains.com/ | |
* | |
* Dual licensed under 'Use it like you stole it' | |
* and 'I Don't Care'. | |
* Description: Toggle checkboxes. Get creative and put them on a timer! Fun! | |
* Example usage: | |
* $(':checkbox').cbToggle(); | |
* OR | |
* $('.cbt :checkbox').cbToggle(); // this will toggle all checkboxes in the .cbt class div, p, span, etc | |
* | |
* Enjoy! | |
*/ | |
$.fn.cbToggle = function() { | |
this.each(function() { | |
$(this).prop('checked', ($(this).prop('checked')) ? false : true); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment