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.
<!DOCTYPE html> <html> <head> <title> JavaScript | uncheck a radio button </title> </head> <body style = "text-align:center;" id = "body"> <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> </body> </html> |
Output:
-
Before clicking on the button:
-
After clicking on the button:
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.
<!DOCTYPE html> <html> <head> <title> JQuery | Uncheck a radio button </title> <script src= </script> </head> <body style = "text-align:center;" id = "body"> <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> </body> </html> |
Output:
-
Before clicking on the button:
-
After clicking on the button:
Recommended Posts:
- How to get value of selected radio button using JavaScript?
- How to know which radio button is selected using jQuery?
- How to check a radio button with jQuery?
- How to check whether a radio button is selected with JavaScript ?
- button tag vs input type="button" attribute
- jQuery | :radio Selector
- HTML | DOM Input Radio Object
- HTML | DOM Input Radio value Property
- HTML | DOM Input Radio name Property
- HTML | <input type="radio">
- HTML | DOM Input Radio checked Property
- HTML | DOM Input Radio autofocus Property
- HTML | DOM Input Radio defaultChecked Property
- HTML | DOM Input Radio type Property
- HTML | DOM Input Radio form Property
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



