jquery 取指定class下的input checkbox选中的值
<!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选中的值的更多相关文章
- jquery(select)下拉框 选取选中的值
var get_date_type=$("#date_type").find("option:selected").val(); var get_date_ty ...
- webform开发经验(一):Asp.Net获取Checkbox选中的值
webform中获取repeat控件列表下的checkbox选中的值: 码农上代码: public static string getSelectedIDs(Repeater Rpt_) { stri ...
- jquery取checkbox选中的值
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/ ...
- [TimLinux] JavaScript 判断 input checkbox选中的方法
1. input属性 <label> <span>选择</span> <input type="checkbox" name=" ...
- jquery.editable-select 可编辑下拉框之获取select值和input值
使用jquery.editable-select可以实现可编辑下拉框的功能,但需要先导入jquery.js,jquery.editable-select.css,jquery.editable-sel ...
- jQuery回车键快速切换下一个input文本框解决方案
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- jquery遍历指定元素下的img图片改变其路径
$(".jieshao img").each(function (i) { $(this).attr("src", "manager/" + ...
- jQuery之获取checkbox选中的值
<mce:script src="jquery.js" mce_src="jquery.js"></mce:script><!-- ...
- input checkbox 选中问题
对html控制不熟的人,估计被checkbox的选中问题发愁了,因为input的checkbox只有选中属性 checked='checked' 但是它有另外一个规则就是Request的时候 只有选中 ...
随机推荐
- vue项目windowServer nginx下部署
https://www.cnblogs.com/jiangwangxiang/p/8481661.html nginx下载地址 http://nginx.org/en/download.html 下载 ...
- web题-自己做的
@sqlmap工具注入 sql基础教程https://jingyan.baidu.com/article/eae078276530621fec5485b9.html 最后啥都有了查询flag表的fla ...
- 【DSP开发】gel文件编写
以下转载自:http://blog.csdn.net/henhen2002/article/details/4573447 GEL--通用扩展语言,无类型语言,只有int类型,当CCS运行时首先执行这 ...
- day37 GIL、同步、异步、进程池、线程池、回调函数
1.GIL 定义: GIL:全局解释器锁(Global Interpreter Lock) 全局解释器锁是一种互斥锁,其锁住的代码是全局解释器中的代码 为什么需要全局解释器锁 在我们进行代码编写时,实 ...
- linux学习命令收集
多看看大神的博客 https://blog.csdn.net/tao934798774/article/details/79491951 ip addr 查看ip地址 ifconfig 查看i ...
- Windows环境下安装Hadoop+Hive的使用案例
Hadoop安装: 首先到官方下载官网的hadoop2.7.7,链接如下 https://mirrors.tuna.tsinghua.edu.cn/apache/hadoop/common/ 找网盘的 ...
- Design HashMap
Design a HashMap without using any built-in hash table libraries. To be specific, your design should ...
- 基于SpringBoot从零构建博客网站 - 整合ehcache和开发注册登录功能
对于程序中一些字典信息.配置信息应该在程序启动时加载到缓存中,用时先到缓存中取,如果没有命中,再到数据库中获取同时放到缓存中,这样做可以减轻数据库层的压力.目前暂时先整合ehcache缓存,同时预留了 ...
- kettle转换设置变量,校验输出新变量
背景:有很多小的转换需要串联起来,如果前一个执行成功,后面继续接着执行,如果执行等待中,就让程序等一会再次获取数据分析,如果失败就中止,成功就进行下一个转换,以此类推.... 需求:通过job把参数传 ...
- 什么是时序时空数据库TSDB
时序时空数据库(Time Series & Spatial Temporal Database,简称 TSDB)是一种高性能.低成本.稳定可靠的在线时序时空数据库服务,提供高效读写.高压缩比存 ...