如果我使用jQuery有多个单选按钮,如何获取单选按钮的值或文本 [英] how to get the value or text of of a radio button if i have multiple radio buttons using jquery

查看:84
本文介绍了如果我使用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


这篇关于如果我使用jQuery有多个单选按钮,如何获取单选按钮的值或文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆