jQuery复选框匹配radiobuttonlist
在我的页面上,我有一个表,其中的行通常如下所示:jQuery复选框匹配radiobuttonlist,jquery,Jquery,在我的页面上,我有一个表,其中的行通常如下所示: <tr class = "child"> <td> <asp:CheckBox ID="CheckBoxEyeProblems" runat="server" /> </td> <td align="center"> <asp:RadioButtonList ID="RadioButto
<tr class = "child">
<td>
<asp:CheckBox ID="CheckBoxEyeProblems" runat="server" />
</td>
<td align="center">
<asp:RadioButtonList ID="RadioButtonListEyeProblems"
<asp:ListItem Value="Y">Yes</asp:ListItem>
<asp:ListItem Value="N">No</asp:ListItem>
</asp:RadioButtonList>
</td>
</tr>
这些就是我的问题。我正在使用ASP.NET 3.5。试试这个
$("tr.child td input:checkbox").click(function(){
var chk = $(this);
//chk.closest("td").next().find("input:radio").attr("disabled",chk.attr("checked"));
// to remove checked attribute you can use
chk.closest("td").next().find("input:radio").attr("checked", false).attr("disabled",chk.attr("checked"));
});
不,您没有使用ASP,而是使用带有ASP生成的标记的jQuery。向我们显示标记(HTML),而不是ASP代码。此页是母版页下的内容页,因此HTML将有大量id损坏。这可能给了我更好的想法,我正在尝试做什么。谢谢你的回复。我只是想知道chk.nexist(“td”)是否可以工作,因为它们在不同的“td”元素中。在禁用任何rb选择之前,如何清除它?尽管这个确切的方法不起作用,但首先,我只需要在取消选中复选框时取消选中复选框,这给了我一个如何完成任务的好主意
$("tr.child td input:checkbox").click(function(){
var chk = $(this);
//chk.closest("td").next().find("input:radio").attr("disabled",chk.attr("checked"));
// to remove checked attribute you can use
chk.closest("td").next().find("input:radio").attr("checked", false).attr("disabled",chk.attr("checked"));
});