Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you get the checked value of asp:RadioButton with jQuery?

I need to do something like this:

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

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())

A little help?

like image 744
Dan Bailiff Avatar asked Oct 08 '09 23:10

Dan Bailiff


1 Answers

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");
like image 138
ChaosPandion Avatar answered Nov 13 '22 04:11

ChaosPandion