我正在学习 jquery,但似乎无法从 asp.net 单选按钮列表中的单选按钮列表中找到所需的单选按钮的值。
这是标记;
<fieldset style="width:50%;">
<legend>Select one option below</legend>
<div id="radioContactTasks">
<asp:RadioButtonList ID="rblAddEditContact" runat="server"
RepeatDirection="Vertical"
CssClass="registerradio" TextAlign="Left">
<asp:ListItem Text="Add New Contact" />
<asp:ListItem Text="Edit Existing Contact" />
<asp:ListItem Text="Delete Existing Contact" />
</asp:RadioButtonList>
</div>
</fieldset>
我尝试了各种方法,都没有奏效。这是最新的变化,只是提醒我选择了什么。
$(document).ready(function () {
$("#rblAddEditContact").on("change", ":radio", function () {
alert($(this).siblings("label").value);
});
});
这是呈现的html
<fieldset style="width:45%;">
<legend>Add New or Edit Exisiting Contacts</legend>
<fieldset style="width:50%;">
<legend>Select one option below</legend>
<div id="radioContactTasks">
<table id="MainContent_rblAddEditContact" class="registerradio">
<tr>
<td><label for="MainContent_rblAddEditContact_0">Add New Contact</label><input id="MainContent_rblAddEditContact_0" type="radio" name="ctl00$MainContent$rblAddEditContact" value="Add New Contact" /></td>
</tr><tr>
<td><label for="MainContent_rblAddEditContact_1">Edit Existing Contact</label><input id="MainContent_rblAddEditContact_1" type="radio" name="ctl00$MainContent$rblAddEditContact" value="Edit Existing Contact" /></td>
</tr><tr>
<td><label for="MainContent_rblAddEditContact_2">Delete Existing Contact</label><input id="MainContent_rblAddEditContact_2" type="radio" name="ctl00$MainContent$rblAddEditContact" value="Delete Existing Contact" /></td>
</tr>