简体   繁体   English

如何使用jquery获取选定的asp单选按钮?

[英]how can i get the selected asp radio button using jquery?

Here is my aspx code and and i selected the first one by default.How I will get the value in Jquery? 这是我的aspx代码,默认情况下我选择了第一个。如何在Jquery中获取值?

<asp:RadioButtonList runat="server" ID="rbDisType" RepeatDirection="Horizontal" CssClass="styleRadioButton">
<asp:ListItem Text="Sale" Value="True" Selected="True"></asp:ListItem>
<asp:ListItem Text="Damage" Value="False"></asp:ListItem>
</asp:RadioButtonList>

Here is the code its reenders.. 这是它的代码。

 <table id="ctl00_ContentPlaceHolder1_rbDisType" class="styleRadioButton ui-buttonset" border="0">
    <tbody><tr>
        <td><input class="ui-helper-hidden-accessible" id="ctl00_ContentPlaceHolder1_rbDisType_0" name="ctl00$ContentPlaceHolder1$rbDisType" value="True" checked="checked" type="radio"><label aria-disabled="false" role="button" aria-pressed="false" class="ui-button ui-widget ui-state-default ui-button-text-only ui-corner-left" for="ctl00_ContentPlaceHolder1_rbDisType_0"><span class="ui-button-text">Sale</span></label></td>

<td><input class="ui-helper-hidden-accessible" id="ctl00_ContentPlaceHolder1_rbDisType_1" name="ctl00$ContentPlaceHolder1$rbDisType" value="False" type="radio"><label aria-disabled="false" role="button" class="ui-button ui-widget ui-state-default ui-button-text-only ui-corner-right ui-state-active" aria-pressed="true" for="ctl00_ContentPlaceHolder1_rbDisType_1"><span class="ui-button-text">Damage</span></label></td>
    </tr>
</tbody></table>

Try this one: 试试这个:

$("input:radio[name$='rbDisType']").click(function(){
      alert($(this).val());
});

First look at the code that gets generated ie look at the source your browser receives. 首先查看生成的代码,即查看浏览器接收的源。 Then via the ID you can easily navigate there with JQuery and read out the value, should be something like this. 然后通过ID可以轻松地使用JQuery导航到那里并读出值,应该是这样的。

$("#rbDisType").val()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用jQuery获取或设置单选按钮列表的选定索引? - How to get or set Selected index of the Radio Button List using jquery? 如何在不使用GroupBox的情况下为单选按钮提供值并确定选定的单选按钮 - How can I give a radio button a value and determine the selected radio button without using a GroupBox 尝试使用ajax / jquery获取所选单选按钮的值 - Trying to get value of selected radio button using ajax/jquery 获取选定的单选按钮不在ASP .NET的列表中 - Get selected radio button not in a list in ASP .NET 如何从单选按钮列表和复选框列表中获取选定的值? - How can I get selected values from radio button list and check box list? 如何不使用if子句而获得所选单选按钮的文本? - How can I get the text of the selected Radio Button without to use the if clause? 如何使用带浮点值的MVC RadioButtonFor选择正确的单选按钮? - How do I get the correct radio button selected using MVC RadioButtonFor with float values? 如何获得单选按钮所选项目的文本? - How do I get the text of the radio button selected item? 如何使用MVVM模式获取组中的选定单选按钮? - How to get selected radio button in group using MVVM pattern? 如何根据选定的单选按钮值传递单选按钮值? - How can i pass radio button values based on the selected one?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM