Jquery 删除表中单选按钮的选中属性
这是我的代码,我想在单击按钮时清除收音机的响应Jquery 删除表中单选按钮的选中属性,jquery,Jquery,这是我的代码,我想在单击按钮时清除收音机的响应 <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">
<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">
但它不起作用,似乎是代码有问题。请有人帮帮我。$('table.x')
是jquery<3.0的正确选择器:
$('#a').click(function() {
$('TABLE.x').find('input').removeAttr('checked');
});
对于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
选择器中没有空格
您要查找的是表中任何类为x的子节点。table.x查找类为x的表。选择器中有一个空格。请尝试以下代码:
$('#a').click(function()
{
$('TABLE.x').find('input').removeAttr('checked');
});
$('#a').click(function()
{
$('TABLE.x').find('input').removeAttr('checked');
});