How to unchecked a radio button using JavaScript/jQuery?
In order to uncheck a radio button, there is a lot of methods available, but we are going to see the most preferred methods.
Example 1: This example unchecks the radio button by using Javascript checked property. The JavaScript Radio checked property is used to set or return the checked state of an Input Radio Button. This property is used to reflect the HTML checked attribute.
html
< h1 style = "color:green;" > GeeksForGeeks </ h1 > < input id = "radio" type = "radio" name = "GFG" value = "GeeksForGeeks" checked>GFG < br >< br > < button onclick = "gfg_Run()" > uncheck </ button > < p id = "GFG_DOWN" style = "color:green;font-size:20px;" ></ p > < script > var el_down = document.getElementById("GFG_DOWN"); function gfg_Run() { var radioButton = document.getElementById("radio"); radioButton.checked = false; el_down.innerHTML = "Unchecked"; } </ script > |
Output:

How to unchecked a radio button using JavaScript/jQuery?
Example 2: This example unchecks the radio button by using jQuery prop() method. The prop() method in jQuery which is used to set or return the properties and values for the selected elements.
html
< script src = </ script > < h1 style = "color:green;" > GeeksForGeeks </ h1 > < input id = "radio" type = "radio" name = "GFG" value = "GeeksForGeeks" checked>GFG < br >< br > < button onclick = "gfg_Run()" > uncheck </ button > < p id = "GFG_DOWN" style = "color:green;font-size:20px;" ></ p > < script > var el_down = document.getElementById("GFG_DOWN"); function gfg_Run() { $("#radio").prop("checked", false); el_down.innerHTML = "Unchecked"; } </ script > |
Output:

How to unchecked a radio button using JavaScript/jQuery?
Please Login to comment...