This is the best example to set value of radio button using jQuery. First find your radio button which you have to check. After that set the checked property of this radio button to true.
$('.rbGender[value="M"]').prop('checked', true);
Deselect radio button in jquery
Simple set the checked property false to all radio button.$('.rbGender').prop('checked', false);
CODE
<!DOCTYPE html> <html> <head> <title>jQuery With Example</title> <script src="http://code.jquery.com/jquery-1.9.1.js" type="text/javascript"></script> <script type="text/javascript"> $(function () { $('.btnCheckMale').click(function (event) { $('.rbGender[value="M"]').prop('checked', true); }); $('.btnCheckFemale').click(function (event) { $('.rbGender[value="F"]').prop('checked', true); }); $('.btnUnCheck').click(function (event) { $('.rbGender').prop('checked', false); }); }); </script> </head> <body> <div> <input type="radio" name="Gender" value="M" class="rbGender" /> Male<br> <input type="radio" name="Gender" value="F" class="rbGender" /> Female<br><br> <button class="btnCheckMale">Check Male</button> <button class="btnCheckFemale">Check Female</button> <button class="btnUnCheck">UnCheck</button> </div> </body> </html>
DISPLAY
Male
Female
Female
No comments :
Please Give Your Feedback