如果我使用jQuery有多个单选按钮,如何获取单选按钮的值或文本

问题描述:

我有一组单选按钮,我想使用jquery来获取所选单选按钮的值,以下是我的代码,但我无法获取该值.


HI i have a group of radio buttons i want to get the value of selected radio button using jquery below is the code how i am doing but i am not able to get the value.


Jquery:-

 <script type="text/javascript">
        var checkedvalue = $('[ID="radio"]:checked').val();
        alert(checkedvalue);
    </script>

<asp:radiobuttonlist  ID="radio" runat="server">
    <asp:ListItem  Text="apple" Selected="True"></asp:ListItem>
    <asp:ListItem Text="redapple"></asp:ListItem>
    <asp:ListItem Text="graps"></asp:ListItem>
    </asp:radiobuttonlist>

can any one pls help me on this

('[ID ="radio"]:checked').val(); 警报(checkedvalue); < /script > < asp:radiobuttonlist ID =" runat 服务器" < asp:ListItem 文本 =" 已选择 真实" < /asp:ListItem > < asp:ListItem 文本 =" < > < asp:ListItem 文本 =" < > < /asp:radiobuttonlist > 谁能帮我这个忙
('[ID="radio"]:checked').val(); alert(checkedvalue); </script> <asp:radiobuttonlist ID="radio" runat="server"> <asp:ListItem Text="apple" Selected="True"></asp:ListItem> <asp:ListItem Text="redapple"></asp:ListItem> <asp:ListItem Text="graps"></asp:ListItem> </asp:radiobuttonlist> can any one pls help me on this


这里是一个堆栈溢出问题,需要您提供答案:

http://stackoverflow.com/questions/1541160/how-do-you-get-the-checked-of-aspradiobutton-with-jquery [
Here is a Stack Overflow question with the answer you need:

http://stackoverflow.com/questions/1541160/how-do-you-get-the-checked-value-of-aspradiobutton-with-jquery[^]



您可以使用JQuery选择器来获取单选按钮的值.请参阅以下链接:
http://www.tutorialspoint.com/jquery/jquery-selectors.htm [ ^ ]
http://api.jquery.com/category/selectors/ [ http://api.jquery.com/id-selector/ [
Hi,
You can use JQuery selectors to get the value of radio buttons. Refer these links:
http://www.tutorialspoint.com/jquery/jquery-selectors.htm[^]
http://api.jquery.com/category/selectors/[^]
http://api.jquery.com/id-selector/[^]

All The Best.
--AK