Reddy
Reddy

Reputation: 1385

Remove Checked attribute of a radio button in a table

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.

Upvotes: 2

Views: 29010

Answers (3)

Joseph Marikle
Joseph Marikle

Reputation: 78530

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.

Upvotes: 9

Chris Snowden
Chris Snowden

Reputation: 5002

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

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

Upvotes: 1

Darkry
Darkry

Reputation: 590

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

Upvotes: 2

Related Questions