4 December 2011

Make a group of checkboxes behave like radiobuttons.

Source code viewer
  1. // Also able do deselect all:
  2. var $unique = $(selector); // change the selector
  3. $unique.click(function() {
  4. $unique.filter(':checked').not(this).removeAttr('checked');
  5. });
  6.  
  7. // You are not able to deselect all, exactly like radio buttons:
  8. var $unique = $(selector); // change the selector
  9. $unique.click(function() {
  10. $unique.removeAttr('checked');
  11. $(this).attr('checked', true);
  12. });
Programming Language: Javascript