uncheck radio button on second click jquery



<div class="col-md-3">
  <div class="form-group" >
    <label for=" " class="ProLabel1">Stage</label>
    <div class="ProInput1">
      <input type="radio" onclick="preshow()" name="prepost"    value="pre" >Pre Chargesheet
      <input  type="radio" onclick="postshow()" name="prepost" value="post">Post Chargesheet
    </div>
  </div>
</div>




<script>
$(function(){
    $('input[name="prepost"]').click(function(){
        var $radio = $(this);

        // if this was previously checked
        if ($radio.data('waschecked') == true)
        {
            $radio.prop('checked', false);
            $radio.data('waschecked', false);
        }
        else
            $radio.data('waschecked', true);

        // remove was checked from other radios
        $radio.siblings('input[name="rad"]').data('waschecked', false);
    });
});
</script>


Download Code Sample

Comments

Post a Comment

Popular posts from this blog

datatable with both top and bottom scroll bar.

Display Loader and disable page while waiting for ajax request

Remove GIT integration from VSCode