Jquery点击表格单位时选中其中的Radio的三个方法
2015-08-19 10:46 假面Wilson 阅读(813) 评论(0) 收藏 举报HTML:
<table>
<tr>
<td>
1<br>
<input type="radio" name="choice" value="1">
</td>
<td>
2<br>
<input type="radio" name="choice" value="2">
</td>
<td>
3<br>
<input type="radio" name="choice" value="3">
</td>
</tr>
</table>
Jquery:
$("td").click(function () {
$('input:radio', this).attr('checked', true);
});
$("td").click(function () {
$(this).find('input:radio').attr('checked', true);
});
$("td").click(function () {
$(this).closest('input:radio').attr('checked',true);
});
浙公网安备 33010602011771号