【发布时间】:2012-07-05 16:23:25
【问题描述】:
我有一个有两列的表。第一列是所有复选框,第二列是属性名称列表。如何选中包含特定文本的表格单元格旁边的复选框?
这是我的桌子:
<table id="table1">
<tr>
<td class="SelectColumn"><span title="Select this attribute">
<input id="chkSelected" type="checkbox" /></span> </td>
<td>Age (required)</td>
</tr>
</table>
这是我对 jQuery 代码的尝试:
$('#[someButton]').click(function () {
var tableRow = $("td:contains('required')").closest('td').find('input');
$(tableRow).attr('checked', true);
});
当我调试这段代码时,tableRow.length 返回 0。
【问题讨论】:
标签: jquery html jquery-ui html-table