How to make a radio button unchecked by clicking it with JavaScript?

You can uncheck a radio button by setting its checked property to false using JavaScript.

To do this we write:

HTML:

<input type="radio" id="radioButton" name="myRadioGroup" onclick="uncheckRadioButton()">
<label for="radioButton">Radio Button</label>

JavaScript:

<script>
    function uncheckRadioButton() {
        const radioButton = document.getElementById('radioButton');
        radioButton.checked = false;
    }
</script>

In this example, we have a radio button with the id "radioButton".

We’ve added an onclick event handler to the radio button that calls the uncheckRadioButton() function when it’s clicked.

In the uncheckRadioButton() function, we get the radio button element using document.getElementById('radioButton').

We set the checked property of the radio button to false, effectively unchecking it.

When you click the radio button, it will become unchecked.