ASP.Net RadioButtonList:使用jQuery来获取ListItem

Sus*_*san 8 c# asp.net jquery radiobuttonlist selecteditem

有2个RadioButtonLists:

Are you a minor?:  oYes  oNo
Do you wish a joint account?:  oYes  oNo
Run Code Online (Sandbox Code Playgroud)

如果第一个问题的答案是肯定的,我想检测对第一个问题的回答,并使用jQuery函数将第二个问题的答案设置为yes.提前致谢.

<asp:Label ID="lblMinfor" CssClass="boldIt" runat="server" Text="Is this account for a minor" Style="float: left; width: 200px;"></asp:Label><br />
<asp:RadioButtonList ID="rdlMinor" runat="server" RepeatDirection="Horizontal" Width="130px" Style="float: left;" BorderStyle="None" RepeatLayout="Flow" ()>
    <asp:ListItem>Yes</asp:ListItem>
    <asp:ListItem Selected="True">No</asp:ListItem>
</asp:RadioButtonList>
<asp:Label ID="lblJoint" CssClass="boldIt" runat="server" Text="Is this for a joint account?" Style="float: left; width: 200px;"></asp:Label><br />
<asp:RadioButtonList ID="rdlJoint" runat="server" RepeatDirection="Horizontal" Width="130px" Style="float: left;" BorderStyle="None" RepeatLayout="Flow">
    <asp:ListItem>Yes</asp:ListItem>
    <asp:ListItem Selected="True">No</asp:ListItem>
</asp:RadioButtonList>
Run Code Online (Sandbox Code Playgroud)

kev*_*v22 11

$('#<%=rdlMinor.ClientID %>').change(function() {
    if($('#<%=rdlMinor.ClientID %> input:checked').val() == 'Yes') 
    {
        $('#<%=rdlJoint.ClientID %>').find("input[value='Yes']").attr("checked", "checked");
    }
});
Run Code Online (Sandbox Code Playgroud)