次のように定義されたチェックボックスとradiobuttonlistがあります。
<asp:CheckBox id="chkChange" runat="server" text="Enable" />
<br />
<asp:RadioButtonList id="rblConsole" runat="server" cssclass="console">
<asp:ListItem text="XBox 360" value="xbox" />
<asp:ListItem text="Playstation 3" value="playstation" />
</asp:RadioButtonList>
これらのコントロールはマスターページのあるコンテンツページにあるため、レンダリングされる実際のhtmlは次のようになります。
<table id="ctl00_ContentPlaceHolder1_rblConsole" class="console" border="0">
<tr>
<td><input id="ctl00_ContentPlaceHolder1_rblConsole_0" type="radio" name="ctl00$ContentPlaceHolder1$rblConsole" value="xbox" /><label for="ctl00_ContentPlaceHolder1_rblConsole_0">XBox 360</label>
</td>
</tr>
<tr>
<td><input id="ctl00_ContentPlaceHolder1_rblConsole_1" type="radio" name="ctl00$ContentPlaceHolder1$rblConsole" value="playstation" /><label for="ctl00_ContentPlaceHolder1_rblConsole_1">Playstation 3</label>
</td>
</tr>
</table>
javascriptで、チェックボックスをクリックして、rblConsoleラジオボタンリストのラジオボタンを無効にします。
jQueryのendswithセレクターを介してラジオボタンを取得しようとしています。
function ToggleEnabled() {
var isChecked = $("*[id$='chkChange']").is(":checked");
if (isChecked) {
$("*[name$='rblConsole'").removeAttr("disabled");
} else {
$("*[name$='rblConsole'").attr("disabled", "disabled");
}
}
では、jQueryを介してこれらを無効にする方法は?