Created
December 29, 2015 14:57
-
-
Save jorgeas80/a531fc3176b489657000 to your computer and use it in GitHub Desktop.
Make radio button deselectable
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
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