一些非常基本的jQuery遇到了一个小问题,我希望能够点击一个表格单元格,然后让它自动选择里面的单选按钮.
HTML:
jQuery的:
- $("td").click(function () {
- $(this).closest('input:radio').attr('checked',true);
- });
任何帮助真的很感激,谢谢!
解决方法
@H_404_15@ 使用此选择器:
- $('input:radio',this).attr('checked',true);
或者使用find方法:
- $(this).find('input:radio').attr('checked',true);
以下是代码的外观:
- $("td").click(function () {
- $(this).find('input:radio').attr('checked',true);
- });