jquery判断RadioButtonList和RadioButton中是否有选中项示例
2019/6/29 22:42:11
本文主要是介绍jquery判断RadioButtonList和RadioButton中是否有选中项示例,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
复制代码 代码如下:
<pre class="html" name="code"> <%--Body 代码--%>
<div>
<asp:RadioButtonList ID="RadioButtonList1" runat="server">
<asp:ListItem Value="A">a</asp:ListItem>
<asp:ListItem Value="B">b</asp:ListItem>
</asp:RadioButtonList>
<asp:RadioButton ID="RadioButton1" GroupName="RBtn" Text="男" runat="server" Checked="true" />
<asp:RadioButton ID="RadioButton2" GroupName="RBtn" Text="女" runat="server" />
<asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="Button1_ClientClick()"></asp:Button>
</div></pre>
复制代码 代码如下:
<pre class="csharp" name="code"><%--Head 代码--%>
<script language="javascript" type="text/javascript" src="js/jquery-1.9.1.js"></script>
<script language="javascript" type="text/javascript">
function Button1_ClientClick()
{
alert($("input[name='RadioButtonList1']:checked").val()); // 若都没有选中,则弹出“undefined”,若有选中的,则弹出对应的 Value 值
if(document.getElementById("RadioButton1").checked==true) // 若RadioButton1被选中
{
alert($("#RadioButton1:checked").val()); //弹出 RadioButton1
alert($("#RadioButton2:checked").val()); //弹出 undefined
alert($("#RadioButton1:checked").val()=="RadioButton1"); //弹出 true
}
return false; //暂时不用传到后台
}
</script>
</pre>
这篇关于jquery判断RadioButtonList和RadioButton中是否有选中项示例的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-03-06jquery对css样式(jquery中的css方法)-icode9专业技术文章分享
- 2023-05-27JQuery的认识和安装
- 2023-01-06JQuery应用技巧:如何定义 HTML 模板并使用 JQuery 进行加载-icode9专业技术文章分享
- 2022-09-29复习-jQuery
- 2022-09-04Python3项目初始化10-->前端基础jquery、ajax,sweetalert--更新用户改造
- 2022-08-30day 27 jquery
- 2022-08-29jQuery筛选器,bootstrap
- 2022-08-20JQuery事件绑定
- 2022-08-20JQuery案例
- 2022-08-07关于jQuery的学习