如何使用 jQuery 获取 asp:RadioButton 的检查值? [英] How do you get the checked value of asp:RadioButton with jQuery?

查看:25
本文介绍了如何使用 jQuery 获取 asp:RadioButton 的检查值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要这样做:

<asp:RadioButton ID="rbDate" runat="server" Text="Date" GroupName="grpPrimary" />

并且能够在 jQuery 中检查单选按钮的选中值的值,但是我这样的尝试不会返回真/假.

and be able to check the value of the radio button's checked value in jQuery, but my attempts like these don't return true/false.

if ($('[name=rbDate]').attr("Checked"))

if ($('[name=rbDate]').attr("Checked").val())

if ($('[name=rbDate]:checked').val())

有点帮助?​​

推荐答案

这可能是最简单的方法.*= 在整个 id 属性中搜索 rbDate,它负责整个 ASP.NET id 修改.

This is probably the easiest way to do it. The *= searches the whole id attribute for rbDate which takes care of the whole ASP.NET id mangling.

$('input[id*=rbDate]').is(":checked");

这篇关于如何使用 jQuery 获取 asp:RadioButton 的检查值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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