Wednesday, July 3, 2019

How to Create Check and Uncheck - Radio Button ?

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

    if (previousValue == 'checked') {
      $(this).removeAttr('checked');
      $(this).attr('previousValue', false);
    } else {
      $("input[name="+name+"]:radio").attr('previousValue', false);
      $(this).attr('previousValue', 'checked');
    }
  });
};

grd('1');

</script>

<input type="radio" name="1" class="radio">
<input type="radio" name="1" class="radio">
<input type="radio" name="1" class="radio">
<input type="radio" name="1" class="radio">
<br>
<input type="radio" name="2" class="radio">
<input type="radio" name="2" class="radio">
<input type="radio" name="2" class="radio">
<input type="radio" name="2" class="radio">

How to Create Check and Uncheck - Radio Button ?

<script> var grd = function(){   $("input[type='radio']").click(function() {     var previousValue = $(this).attr(...

Popular Posts