Skip to content

Instantly share code, notes, and snippets.

@s-aska s-aska/gist:4117005
Created Nov 20, 2012

Embed
What would you like to do?
もう一回クリックしたらチェックが外れるラジオボタン
var radio_map = {};
$('input[type="radio"]').click(function(){
var input = $(this);
var name = input.attr('name');
if (radio_map[name] === input.val()) {
radio_map[name] = null;
input.attr('checked', false);
} else {
radio_map[name] = input.val();
}
}).each(function(){
var input = $(this);
if (input.prop('checked')) {
var name = input.attr('name');
radio_map[name] = input.val();
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.