<!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){

jquery 取指定class下的input checkbox选中的值的更多相关文章

  1. jquery(select)下拉框 选取选中的值

    var get_date_type=$("#date_type").find("option:selected").val(); var get_date_ty ...

  2. webform开发经验(一):Asp.Net获取Checkbox选中的值

    webform中获取repeat控件列表下的checkbox选中的值: 码农上代码: public static string getSelectedIDs(Repeater Rpt_) { stri ...

  3. jquery取checkbox选中的值

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/ ...

  4. [TimLinux] JavaScript 判断 input checkbox选中的方法

    1. input属性 <label> <span>选择</span> <input type="checkbox" name=" ...

  5. jquery.editable-select 可编辑下拉框之获取select值和input值

    使用jquery.editable-select可以实现可编辑下拉框的功能,但需要先导入jquery.js,jquery.editable-select.css,jquery.editable-sel ...

  6. jQuery回车键快速切换下一个input文本框解决方案

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  7. jquery遍历指定元素下的img图片改变其路径

    $(".jieshao img").each(function (i) { $(this).attr("src", "manager/" + ...

  8. jQuery之获取checkbox选中的值

    <mce:script src="jquery.js" mce_src="jquery.js"></mce:script><!-- ...

  9. input checkbox 选中问题

    对html控制不熟的人,估计被checkbox的选中问题发愁了,因为input的checkbox只有选中属性 checked='checked' 但是它有另外一个规则就是Request的时候 只有选中 ...

随机推荐

  1. Selenium 2自动化测试实战40(单线程)

    单线程 #onethread.py #coding:utf-8 from time import sleep,ctime #听音乐任务 def music(): print('i was listen ...

  2. 一个简单的C共享库的创建及Python调用此库的方法

    /********************************************************************* * Author  : Samson * Date    ...

  3. Redis4.0.11在linux上面安装时候编译的输出

    root@iZ2zedo02x7n4nuc3lb4ueZ:/opt/redis-4.0.11/src# make install CC Makefile.deprm -rf redis-server ...

  4. 转载:深入理解Spring MVC 思想

    原文作者:赵磊 原文地址:http://elf8848.iteye.com/blog/875830 目录  一.前言二.spring mvc 核心类与接口三.spring mvc 核心流程图 四.sp ...

  5. 【miscellaneous】单播、广播和多播IP地址

    转自:http://www.cnblogs.com/gaoxing/archive/2012/02/19/2358484.html 除地址类别外,还可根据传输的消息特征将IP地址分为单播.广播或多播. ...

  6. 深入理解C语言-函数指针

    函数指针在C++中有着重要的应用,函数的函数名其本质就是代表一个地址,这个地址叫做函数入口,得到这个地址就可以对这个函数进行各种操作. 函数类型基础 函数三要素: 名称.参数.返回值 C语言中的函数有 ...

  7. 如何写出优雅耐看的JavaScript代码

    参考链接:https://segmentfault.com/a/1190000020444918?utm_medium=hao.caibaojian.com&utm_source=hao.ca ...

  8. English 邮件

    1.email http://www2.elc.polyu.edu.hk/cill/eiw/e-mail.htm

  9. 阿里云云计算ACP专业认证考试

    阿里云云计算专业认证(Alibaba Cloud Certified Professional,ACP)是面向使用阿里云云计算产品的架构.开发.运维类人员的专业技术认证. 更多阿里云云计算ACP专业认 ...

  10. 怎么将本地项目放到码云(gitee)上面?图文详解

    git的好处什么的,在此就不多赘述.现在很多公司都在用git了. 那么怎么将本地已经有的项目放到码云(gitee)上呢? 前置条件说明: 1:原来项目所在位置:D:\workspace01\class ...