0

I have a table with a lot of radio buttons. There is a "clear all" button that deselects everything. I am using similar code to perform it:

<input type="radio" name="selections[1]" id="selections_1_3" value="">

<script>
$('#button').click(function(){
    $('#selections_1_3').prop('checked', false);
});
</script>

It works fine, the only issue is that the next time I try to select a button that was deselected via this code, I have to click twice because somehow the button may still be with checked attribute and performs nothing with a single click.

I have tried mouseup(), keyup(), and refresh(); but nothing solves.

ace
  • 313
  • 1
  • 5
  • 19
  • This might point you in the right direction. http://stackoverflow.com/questions/17420534/check-uncheck-checkbox-using-jquery – Ty T. Nov 30 '16 at 03:44
  • @user3262111 that's exactly what I'm doing... – ace Nov 30 '16 at 03:48
  • @HenryDev the code is up there – ace Nov 30 '16 at 03:48
  • the question is very simple and direct but it's everything there.. if you have a page with radio buttons that simple line unchecked everything, I just want the other line to "refresh" the button so I don't need to click twice on the next time I have to select it. I don't know what you would like to see more.. – ace Nov 30 '16 at 03:51
  • it's exactly the same thing I am currently doing... – ace Nov 30 '16 at 03:54

1 Answers1

1

The code you are using is working fine for me as shown in the below code snippet

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="radio" name="selections[1]" id="selections_1_1" value="">
<input type="radio" name="selections[2]" id="selections_1_2" value="">
<input type="radio" name="selections[3]" id="selections_1_3" value="">
<input type="radio" name="selections[4]" id="selections_1_4" value="">
<input type="button" id="button">
<script>
$('#button').click(function(){
    $('#selections_1_1').prop('checked', false);
  $('#selections_1_2').prop('checked', false);
  $('#selections_1_3').prop('checked', false);
  $('#selections_1_4').prop('checked', false);
});
</script>
GraveyardQueen
  • 771
  • 1
  • 7
  • 17
  • that's correct! I'll have to analyse what's causing this incompatibility. btw thanks – ace Nov 30 '16 at 15:51