<!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 验证被选中的复选框个数</title>
<script language="javascript" src="jquery-1.7.1.min.js"></script>
</head>
<body>
<form action="" name="frm1" id="frm1" method="post">
<input type="checkbox" name="id" value="1" /><br />
<input type="checkbox" name="id" value="2" /><br />
<input type="checkbox" name="id" value="3" /><br />
<input type="button" value="提交" id="btn" />
</form>
<script type="text/javascript">
$("#btn").click(function(){
alert($("input[name='id']:checked").length);
})
</script>
</body>
</html>
jQuery 验证被选中的复选框个数
最新推荐文章于 2023-03-04 19:07:58 发布