Created
November 20, 2012 09:42
-
-
Save s-aska/4117005 to your computer and use it in GitHub Desktop.
もう一回クリックしたらチェックが外れるラジオボタン
This file contains 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 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