Created
March 25, 2025 12:34
-
-
Save stiig/d6c28416ad0ebb49968037d5f576b367 to your computer and use it in GitHub Desktop.
Solution for making radio buttons uncheckable
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
$('.radio_with_uncheck').on('click', 'input[type="radio"]', function() { | |
var $radio = $(this); | |
var group = $('input[name="' + this.name + '"]'); | |
if ($radio.prop('checked') && $radio.data('was-checked')) { | |
$radio.prop('checked', false); | |
} | |
group.data('was-checked', false); | |
$radio.data('was-checked', $radio.prop('checked')); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment