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>
&l开发者_JAVA技巧t;/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.
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.
$('table.x')
is the right selector
There was a space in the selector. Try the code below:
$('#a').click(function()
{
$('TABLE.x').find('input').removeAttr('checked');
});
精彩评论