使用jquery 获取RadioButtonList 中选中值

方法1:摘自网络

<mce:script language="javascript"><!-- $(document).ready(function() { $("#btnSubmit").click(function() { alert($("#RadioButtonList1").find("input[@checked]").val()); }); }); // --></mce:script> <asp:RadioButtonList ID="RadioButtonList1" runat="server"> <asp:ListItem>1</asp:ListItem> <asp:ListItem>2</asp:ListItem> <asp:ListItem>3</asp:ListItem> </asp:RadioButtonList> <input id="btnSubmit" type="button" value="Submit" />

方法2:原创

var rubricType = $("input[name='rblRubricType']:checked").val(); <mce:script language="javascript"><!-- $(document).ready(function() { $("#btnSubmit").click(function() { alert($("input[name='RadioButtonList1']:checked").val()); }); }); // --></mce:script> <asp:RadioButtonList ID="RadioButtonList1" runat="server"> <asp:ListItem>1</asp:ListItem> <asp:ListItem>2</asp:ListItem> <asp:ListItem>3</asp:ListItem> </asp:RadioButtonList> <input id="btnSubmit" type="button" value="Submit" />

两种方法都可以,我只我认为第二种比较好理解一些

你可能感兴趣的:(JavaScript,jquery,function,input,asp,button)