Skip to content
Related Articles

Related Articles

How to unchecked a radio button using JavaScript/jQuery?
  • Last Updated : 07 May, 2019

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:

full-stack-img




My Personal Notes arrow_drop_up
Recommended Articles
Page :