我看了,找不到我的问题的简单答案.我点击其中一个,TR
然后点击另一个TR
,它工作正常,但在点击两个后,它不再识别点击一行.有帮助吗?这是HTML:
<table>
<th>1</th>
<th>2</th>
<tr>
<td>Yes
<input type='radio' name='test' value='yes' />
</td>
</tr>
<tr>
<td>No
<input type='radio' name='test' value='no' />
</td>
</tr>
</table>
Run Code Online (Sandbox Code Playgroud)
这是jquery
$(function () {
$('table tr').click(function () {
$(this).find('input:radio').attr('checked', 'checked');
});
});
Run Code Online (Sandbox Code Playgroud)
您需要通过设置已检查的属性.prop()
:
$(this).find('input:radio').prop('checked', true);
Run Code Online (Sandbox Code Playgroud)