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">

5 comments:

  1. Nice articel, This article help me very well. Thank you. Also please check my article on my site Know All About Web Tutorial.

    ReplyDelete
  2. "Dear Admin,
    I am Jamal Lloyd Johnson. Very informative post! I am thankful to you for providing this unique information.
    Jamal Lloyd Johnson
    Apollo Management:Mail: 1236 N. Sweetzer Ave, unit 17
    West Hollywood, CA 90069
    Jamal Lloyd Johnson
    Jamal Lloyd Johnson
    Jamal Lloyd Johnson
    Jamal Lloyd Johnson"

    ReplyDelete
  3. Nice Article, Blog theme is also very user friendly. Tech information is also good on this blog. Also checkout - Magento 2.4 Features
    Thanks

    ReplyDelete
  4. Nice tutorial. I have written a similar tutorial at my site please check it css important

    ReplyDelete
  5. You can also learn Cdn Reactjs, a declarative, efficient, and flexible JavaScript library.

    ReplyDelete

How to Create Check and Uncheck - Radio Button ?

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

Popular Posts