代码说

code is poetry

代码说    
碎碎念:划破夜空,赛车让你热血沸腾!  换一换

验证radio选项组中是否有选项已经被选

作者:coderzheng 发布于:2013-5-26 12:02 Sunday 分类:jquery  阅读模式

<!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>test</title>
<script type="text/javascript" src="js/jquery-1.3.2.js"></script>
<script type="text/javascript">
$(function(){
	$('#tt').click(function() {
		var rd = $("input[type=radio][name=area]:checked").val();
		if ( typeof(rd) == 'undefined') {
			alert('aaa');
		}
			alert(typeof(rd));
	});
});
</script>
</head>

<body>
<input type="radio" name="area" value="1" />111<input type="radio" name="area" value="2" />222
<input type="button" value="Test" id="tt" />
</body>
</html>

标签: javascript jquery

你可以发表评论、引用到你的网站或博客,或通过RSS 2.0订阅这个博客的所有文章。
上一篇: 在select下拉框中同时设置两组值  |  下一篇:js邮箱验证正则表达式