我有一个包含几行的HTML表格,每一行都有一个单选按钮,我尝试将每一行作为一个链接,即当它被选中并且它的单选按钮被选中时会改变颜色以获得与单选按钮关联的id,我只能做到表格的每一行都是一个链接。我该怎么做?
<script type="text/javascript">
$(".desmarcado").click(function () {
$("#intereses").prop("checked", true);
$(".desmarcado td").each(function (index) {
alert($(this).text());
});
});
</script>
我的桌子是这个
<table id="table" class="table">
<thead>
<tr>
<th></th>
<th></th>
<!--<th></th>-->
</tr>
</thead>
<tbody>
<tr style='cursor:pointer' class='desmarcado'>
<td><input id="intereses" name="intereses" type="radio" value="1" /></td>
<td>Persona 1</td>
</tr>
</tbody>
</table>
注意:我添加了年龄列以查看片段的功能。
您的解决方案如下所示:
这将是一个解决方案: