jquery判断RadioButtonList和RadioButton中是否有选中项示例
jQuery 示例 判断 是否 选中 RadioButton radiobuttonlist
2023-06-13 09:15:06 时间
<preclass="html"name="code"><%--Body代码--%>
<div>
<asp:RadioButtonListID="RadioButtonList1"runat="server">
<asp:ListItemValue="A">a</asp:ListItem>
<asp:ListItemValue="B">b</asp:ListItem>
</asp:RadioButtonList>
<asp:RadioButtonID="RadioButton1"GroupName="RBtn"Text="男"runat="server"Checked="true"/>
<asp:RadioButtonID="RadioButton2"GroupName="RBtn"Text="女"runat="server"/>
<asp:ButtonID="Button1"runat="server"Text="Button"OnClientClick="Button1_ClientClick()"></asp:Button>
</div></pre>
<preclass="csharp"name="code"><%--Head代码--%>
<scriptlanguage="javascript"type="text/javascript"src="js/jquery-1.9.1.js"></script>
<scriptlanguage="javascript"type="text/javascript">
functionButton1_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
}
returnfalse;//暂时不用传到后台
}
</script>
</pre>
相关文章
- jQuery Tips(5)—-关于伪类选择符详解编程语言
- jquery websocket 插件详解编程语言
- jQuery选择器是什么
- jQuery技巧大放送学习jquery的朋友可以看下
- jQuery判断元素是否是隐藏的代码
- 基于jQuery判断两个元素是否有重叠部分的代码
- jQuery学习笔记获取jQuery对象
- JQuery入门—编写一个简单的JQuery应用案例
- jQuery插件开发基础简单介绍
- 利用JQuery动画制作滑动菜单项效果实现步骤及代码
- JQuery为textarea添加maxlength属性并且兼容IE
- jQuery+JSON+jPlayer实现QQ空间音乐查询功能示例
- jquery可见性过滤选择器使用示例
- 简单实用jquery版三级联动select示例
- 浅析Js(Jquery)中,字符串与JSON格式互相转换的示例(直接运行实例)
- jQuery.attr()和.removeAttr()方法操作元素属性示例
- jquery$.each和for怎么跳出循环终止本次循环
- jQuery中$.fn的用法示例介绍
- Jquery插件easyUi表单验证提交(示例代码)
- jquery教程ajax请求json数据示例
- jquery鼠标滑动显示详情应用示例
- php和jquery实现地图区域数据统计展示数据示例
- jquery实现省市select下拉框的替换(示例代码)
- jquery模拟LCD时钟的html文件源代码