January 15, 2016
How to Uncheck a Radio Button Using JavaScript
To uncheck a radio button in JavaScript, we make use of checked property. Its value can be true or false. Example is given below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
<html> <head> <title>JavaScript Tutorial </title> <script type="text/javascript"> function Check() { //Check a radio button. document.getElementById("myRadio").checked = true; } function Uncheck() { //Uncheck a radio button. document.getElementById("myRadio").checked = false; } </script> </head> <body> My Radio Button: <input id="myRadio" type="radio" /> <input type="button" value="Check" onclick="Check()"/> <input type="button" value="Uncheck" onclick="Uncheck()"/> </body> </html> |