<!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>属性选择器学习</title>
<script language="JavaScript" type="text/javascript" src="http://www.jq22.com/jquery/jquery-3.3.1.js"></script>
<script language="javascript" type="text/javascript">
//使用jquery加载事件
$(document).ready(function (){
$("#btn1").click(function (){var che = [];
          // 取name getElementsByName("ccq")
obj = document.getElementsByClassName("c1");
console.log(obj)
check_val = [];
for(k in obj){
if(obj[k].checked)
check_val.push(obj[k].value);
}
console.log(check_val)
console.log($("input[class=c1]:checked").length);
// alert($("input[type=checkbox]:checked").length);
// $('input:checkbox:checked') 等同于 $('input[type=checkbox]:checked')
// 选name 则是$("input[name=ccq]:checked")
$.each($("input[class=c1]:checked"),function(i){
// window.alert("你选了:"+
// $('input[type=checkbox]:checked').length+"个,其中有:"+$(this).val());
che.push($(this).val());
console.log(i);
});
console.log(che);
});</script>
</head>
<body>
<form method="post" action="">
<input class="c1" name="ccq" type="checkbox" value="美女" />美女
<input class="c1" name="ccq" type="checkbox" value="美男" />美男
<input class="c1" name="ccq" type="checkbox" value="大爷" />大爷
<input class="c2" name="ccq" type="checkbox" value="大妈" />大妈
<br>
<input type="radio" value="男" />男
<input type="radio" value="女" />女
<br>
<select id="zhiwei" size="5" multiple="multiple">
<option>PHP开发工程师</option>
<option>数据库管理员</option>
<option>系统分析师</option>
<option>保安</option>
</select>
<select id="xueli">
<option>大专</option>
<option>中专</option>
<option>小学</option>
</select>
</form>
<div style="clear:both;">
<input id="btn1" type="button" value="" /><br>
</div>
</body>
</html>
 $.each($("input[class=c1]:checked"),function(i){

最新文章

  1. phpMyAdmin提示:配置文件权限错误,无法写入!解决方法
  2. IO调度算法
  3. JS中变量名作为if条件的 true/flase
  4. NES模拟器开发-CPU笔记
  5. VS2010 C++环境下DLL和LIB文件目录及名称修改
  6. php 批量生成html、txt文件
  7. VS2010调试 --指南 Reference from : http://blog.csdn.net/kingzone_2008/article/details/8133048
  8. jni使用
  9. 201521123017 《Java程序设计》第7周学习总结
  10. layer与iframe 间值的相互传递
  11. 51nod 1686 第k大区间
  12. Redis之(二)数据类型及存储结构
  13. python初级实战-----关于邮件发送问题
  14. python3-元类
  15. Java Lambda 表达式 对 Map 对象排序
  16. switch嵌套--猜拳游戏
  17. c语言数据类型、运算符和表达式
  18. 关于while(cin&gt;&gt;c)语句的理解
  19. 【jemter】HTTP请求参数化
  20. mysql添加一个字段(

热门文章

  1. Cloudera Manager产品介绍
  2. 启动nfs清除端口占用过程
  3. Vue对象提供的属性功能
  4. 加入域之后,【Internet 时间】选项没有了
  5. 【机器学习】QQ-plot深入理解与实现
  6. NPM安装过程中的一些问题与解决
  7. Appendix 2- Lebesgue integration and Reimann integration
  8. 分库分表之后,id 主键如何处理
  9. 【转】nosql的分类
  10. 斜率优化DP(转载)