How to uncheck a radio button?

How to uncheck a radio button?

I have group of radio buttons that I want to uncheck after an AJAX form is submitted using jQuery. I have the following function:
function clearForm(){
$(‘#frm input[type=”text”]’).each(function(){
$(‘#frm input[type=”radio”:checked]’).each(function(){
$(this).checked = false;

With the help of this function, I can clear the values at the text boxes, but I can’t clear the values of the radio buttons.
By the way, I also tried $(this).val(“”); but that didn’t work.


Solution 1:

either (plain js)

this.checked = false;

or (jQuery)

$(this).prop('checked', false);
// Note that the pre-jQuery 1.6 idiom was
// $(this).attr('checked', false);

See jQuery prop() help page for an explanation on the difference between attr() and prop() and why prop() is now preferable.
prop() was introduced with jQuery 1.6 in May 2011.

Solution 2:

You wouldn’t need the each function

$("input:radio").attr("checked", false);



The same should also apply to your textbox:

$('#frm input[type="text"]').val("");

But you could improve this

$('#frm input:text').val("");

Solution 3:



Since a lot of browsers will interpret ‘checked=anything’ as true. This will remove the checked attribute altogether.

Hope this helps.

Solution 4:

Slight modification of Laurynas’ plugin based on Igor’s code. This accommodates possible labels associated with the radio buttons being targeted:

(function ($) {
    $.fn.uncheckableRadio = function () {

        return this.each(function () {
            var radio = this;
                $('label[for="' + + '"]').add(radio).mousedown(function () {
                    $(radio).data('wasChecked', radio.checked);

                $('label[for="' + + '"]').add(radio).click(function () {
                    if ($(radio).data('wasChecked'))
                        radio.checked = false;

Solution 5:

Thanks Patrick, you made my day! It’s mousedown you have to use. However I’ve improved the code so you can handle a group of radio buttons.

//We need to bind click handler as well
//as FF sets button checked after mousedown, but before click
$('input:radio').bind('click mousedown', (function() {
    //Capture radio button status within its handler scope,
    //so we do not use any global vars and every radio button keeps its own status.
    //This required to uncheck them later.
    //We need to store status separately as browser updates checked status before click handler called,
    //so radio button will always be checked.
    var isChecked;

    return function(event) {
        //console.log(event.type + ": " + this.checked);

        if(event.type == 'click') {

            if(isChecked) {
                //Uncheck and update status
                isChecked = this.checked = false;
            } else {
                //Update status
                //Browser will check the button by itself
                isChecked = true;

                //Do something else if radio button selected
                if(this.value == 'somevalue') {
                } else {
    } else {
        //Get the right status before browser sets it
        //We need to use onmousedown event here, as it is the only cross-browser compatible event for radio buttons
        isChecked = this.checked;

Solution 6:

Rewrite of Igor’s code as plugin.




(function( $ ){

    $.fn.uncheckableRadio = function() {

        return this.each(function() {
            $(this).mousedown(function() {
                $(this).data('wasChecked', this.checked);

            $(this).click(function() {
                if ($(this).data('wasChecked'))
                    this.checked = false;


})( jQuery );