Skip to content

Instantly share code, notes, and snippets.

@jorgeas80
Created December 29, 2015 14:57
Show Gist options
  • Save jorgeas80/a531fc3176b489657000 to your computer and use it in GitHub Desktop.
Save jorgeas80/a531fc3176b489657000 to your computer and use it in GitHub Desktop.
Make radio button deselectable
var makeRadiosDeselectableByName = function(name){
$('input[name=' + name + ']').click(function() {
if($(this).attr('previousValue') == 'true'){
$(this).attr('checked', false)
} else {
$('input[name=' + name + ']').attr('previousValue', false);
}
$(this).attr('previousValue', $(this).attr('checked'));
});
};
// Taken from http://stackoverflow.com/a/6191732/593722
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment