javascript - How to get selected value of list item in radio button list in jquery -
i have radio radiobuttonlist has 3 radio buttons, want boolean value (true or false) when of radio button selected.
<asp:radiobuttonlist runat="server" id = "test" clientidmode="static"> <asp:listitem text="male" value="1" /> <asp:listitem text="male" value="2" /> <asp:listitem text="male" value="3" /> </asp:radiobuttonlist> for ex :- have selected first i.e [0] radio button
var radio = $("#test"); var value = $(radio).find("[type=radio]")[0].checked; but didn't work.
i solve problem way:
$("#test").find('input[type=radio]').change(function() { var value = $("#test").find('input[type=radio]:checked').val(); alert(value); }) this way notice when change happens radio buttons , alert value of checked one.
here fiddle: fiddle it's working described. need apply common names inputs. can via:
<asp:radiobutton groupname="string" /> updated fiddle code + input names.
Comments
Post a Comment