jquery怎么获取radio选中的值
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>JQuery radio</title>
<script type="text/javascript" language="javascript" src="JavaScript/jquery-1.6.1.min.js" ></script>
<script type="text/javascript" language="javascript">
/*------判断radio是否有选中,获取选中的值--------*/
$(function(){
$("#btnSubmit").click(function(){
var val=$('input:radio[name="sex"]:checked').val();
if(val==null){
alert("什么也没选中!");
return false;
}
else{
alert(val);
}
var list= $('input:radio[name="list"]:checked').val();
if(list==null){
alert("请选中一个!");
return false;
}
else{
alert(list);
}
});
});
</script>
</head>
<body>
<form id="form1" >
<input type="radio" name="sex" value="男" />男
<input type="radio" name="sex" value="女" />女
<br />
<input type="radio" name="list" value="十分满意" />十分满意
<input type="radio" name="list" value="满意" />满意
<input type="radio" name="list" value="不满意" />不满意
<input type="radio" name="list" value="非常差" />非常差
<br />
<input type="submit" value="submit" id="btnSubmit" />
</form>
</body>
</html>
jquery怎么获取radio选中的值的更多相关文章
- jquery 获取radio选中的值
如下案例:常用方法 1.获取选中值,三种方法都可以: $('input:radio:checked').val(): $("input[type='radio']:checked" ...
- jQuery之获取checkbox选中的值
<mce:script src="jquery.js" mce_src="jquery.js"></mce:script><!-- ...
- jQuery之获取select选中的值
本来以为jQuery("#select1").val();是取得选中的值, 那么jQuery("#select1").text();就是取得的文本. 这是不正确 ...
- JQuery 如何获取select选中的值
一.html代码 <select id="ddl"> <option value="100" emoney="12" &g ...
- jquery中获取radio选中值的正确写法
错误写法: //只在IE下有作用,其他浏览器均获取的为第一个单选框的值 $('input[type=radio]').val(); 正确写法为: //兼容所有浏览器写法 $('input[type=r ...
- Jquery获取radio选中的值
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- js获取radio选中索引值
<form name="form1" onsubmit="return foo()"> <input type="radio&quo ...
- jquery动态选中radio,获取radio选中值
//动态选中radio值,1:表示radio的name 2:表示后台传过来的radio值$(":radio[name='1'][value='" + 2 + "']&qu ...
- jQuery操作复选框checkbox技巧总结 ---- 设置选中、取消选中、获取被选中的值、判断是否选中等
转载:https://blog.csdn.net/chenchunlin526/article/details/77448168 jQuery操作复选框checkbox技巧总结 --- 设置选中.取消 ...
随机推荐
- Sql中时间只取年或者年月
select Title,datepart(year,DateCreated) from CMS_Content 只取年 只显示年月,不显示日:select datepart(year,getd ...
- 使用Crowd2.7集成Confluence5.3与JIRA6.1,并安装、破解及汉化,实现单点登录【原创】
鉴于目前没有针对Crowd.Confluence.Jira安装.集成和破解最新的方法,总结今天安装.破解及集成的经验,编写此文,方便大家进行配置也方便自己以后参考.此文参考多篇破解文章,并经过作者 ...
- windows8.1下php环境搭建及基本配置(php+apache+mysql)
一.php下载安装:php-5.6.1-Win32-VC11-x64.zip.解压,操作: 1.复制php.ini-production,更名为php.ini 2.在环境变量PATH末尾添加:D:\p ...
- java运算符
赋值运算符 int num1=10; int num2=30; System.out.println(num1+num2); 算术运算符 int num=20; System.out.println( ...
- JS数组中every(),filter(),forEach(),map(),some()方法学习笔记!
ES5中定义了五种数组的迭代方法:every(),filter(),forEach(),map(),some(). 每个方法都接受两个参数:要在每一项运行的函数(必选)和运行该函数的作用域的对象-影响 ...
- Visual Studio 不生成.vshost.exe和.pdb文件的方法【转】
Visual Studio 不生成.vshost.exe和.pdb文件的方法[转] 使用Visual Studio编译工程时,默认设置下,即使选择了「Release」时也会生成扩展名为「.vshost ...
- 生成linux shadow文件
-salt $(< /dev/urandom ) -stdin $$cVcjk1yK$sfdBsYIEr800Mdr3PsICe0 $$oBrzawaF$WeVJjd2eyoEEmJykNtMH ...
- ldap日志
要开启openldap的日志功能是非常简单的:1.在slapd.conf中加一行:loglevel 4095 2.在/etc/rsyslog.conf 中加入ldap日志文档: ...
- NSLOG打印不全的问题
#ifdef DEBUG #define NSLog(FORMAT, ...) fprintf(stderr, "%s:%zd\t%s\n", [[[NSString string ...
- webpack vuejs项目学习心得
最近在做移动端的项目,最近webpack和vuejs很火,就想到了用vuejs webpack来构建我的项目 先了解了一些webpack的入门基础 http://webpack.github.io/d ...