2

Here is my code, i want to clrae the response of radio when i click on the button.

<table class='x'>
<tr><td><input type="radio"></td></tr>
<tr><td><input type="text"></td></tr>
</table>
<input type='button' id="a" value="dfrfvrgv">

Here is the jQuery code

$('#a').click(function()
          {
              $('TABLE .x').find('input').removeAttr('checked');  
          });

But it is not working, Seems to be problem with the code. Please someone help me.

Reddy
  • 1,327
  • 3
  • 23
  • 44

3 Answers3

9

For jquery < 3.0:

$('#a').click(function() {
            $('TABLE.x').find('input').removeAttr('checked');  
        });

For jquery >= 3.0:

$('#a').click(function() {
            $('TABLE.x').find('input').prop('checked', false);  
        });

// More info about removeAttr and prop you can find here https://stackoverflow.com/questions/6169826/propchecked-false-or-removeattrchecked

No space in the selector

What you are looking for with the space in there, are any child nodes of TABLE that have the class x. table.x looks for a table with the class of x.

Krzysztof Raciniewski
  • 4,735
  • 3
  • 21
  • 42
Joseph Marikle
  • 76,418
  • 17
  • 112
  • 129
2

$('table.x') is the right selector

Darkry
  • 590
  • 2
  • 12
  • 26
1

There was a space in the selector. Try the code below:

$('#a').click(function()
          {
              $('TABLE.x').find('input').removeAttr('checked');  
          });
Chris Snowden
  • 4,982
  • 1
  • 25
  • 34