Skip to content

Instantly share code, notes, and snippets.

@frnhr
Created November 1, 2012 00:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save frnhr/3990773 to your computer and use it in GitHub Desktop.
Save frnhr/3990773 to your computer and use it in GitHub Desktop.
uncheckable radio buttons
/**
* Uncheckable radio buttons o_O
*
* usage:
* <input type="radio" name="something" class="uncheckable" />
*/
$('input[type=radio].uncheckable').on('click', function(event){
var $this = $(this);
var was_checked = $this.data('checked');
$('input[name='+$this.prop('name')+']').data('checked', false);
$this.data('checked', !was_checked).prop('checked', !was_checked);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment