How to set value of radio button in jQuery

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);
<!DOCTYPE html>
  <title>jQuery With Example</title>
  <script src="" 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);
    <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>

No comments :

Please Give Your Feedback