方法checkbox选中一个另一个checkbox也会选中的实现代码_jquery

checkbox选中  时间:2021-04-22  阅读:()

checkbox选中一个另一个checkbox也会选中的实现代码

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' >

<head>

<meta http-equiv='content-type' content=' text/html; charset=utf-8' /><meta http-equiv='content-language' content='en-us' />

<title>CheckBox select</title>

<script type=' text/javascript' src=' jquery-3.0.0. js' ></script><script type=' text/javascript' >

$(document) .ready(function() {

/****----全选----****/

//$('#check1' ) .on('change' ,function() {

//$("#check1") .bind("click",function() {

$('#check1' ) .on('click' ,function() {

//方法一if(this.checked==true) {

$(' input' ) .prop('checked' , true) ;

}else{

$(' input' ) .prop('checked' ,false) ;

}if($(".do") . text()=="全选") {

$(".do") . text("取消") ;

}else{

$(".do") . text("全选") ;

}

//方法二

//$(' input[type=checkbox] ' ) .prop('checked' , $(this) .prop('checked' ) ) ;} ) ;

/****----第一列----****/

$('#checkl1' ) .on('click' ,function() {

//方法一if(this.checked==true) {

$('#check11,#check21,#check31,#check41,#check51' ) .prop('checked' , true) ;

}else{

$('#check11,#check21,#check31,#check41,#check51' ) .prop('checked' ,false) ;

}

//方法二如上

} ) ;

/****----第二列----****/

$('#checkl2' ) .on('click' ,function() {

//方法一if(this.checked==true) {

$('#check12,#check22,#check32,#check42,#check52' ) .prop('checked' , true) ;

}else{

$('#check12,#check22,#check32,#check42,#check52' ) .prop('checked' ,false) ;

}

//方法二如上

} ) ;

/****----第三列----****/

$('#checkl3' ) .on('click' ,function() {

//方法一if(this.checked==true) {

$('#check13,#check23,#check33,#check43,#check53' ) .prop('checked' , true) ;

}else{

$('#check13,#check23,#check33,#check43,#check53' ) .prop('checked' ,false) ;

}

//方法二如上

} ) ;

/****----第四列----****/

$('#checkl4' ) .on('click' ,function() {

//方法一if(this.checked==true) {

$('#check14,#check24,#check34,#check44,#check54' ) .prop('checked' , true) ;

}else{

$('#check14,#check24,#check34,#check44,#check54' ) .prop('checked' ,false) ;

}

//方法二如上

} ) ;

/****----第一行----****/

$('#checkh1' ) .on('click' ,function() {

//方法一if(this.checked==true) {

$('#check11,#check12,#check13,#check14' ) .prop('checked' , true) ;}else{

$('#check11,#check12,#check13,#check14' ) .prop('checked' ,false) ;}

//方法二如上

} ) ;

/****----第二行----****/

$('#checkh2' ) .on('click' ,function() {

//方法一if(this.checked==true) {

$('#check21,#check22,#check23,#check24' ) .prop('checked' , true) ;}else{

$('#check21,#check22,#check23,#check24' ) .prop('checked' ,false) ;}

//方法二如上

} ) ;

/****----第三行----****/

$('#checkh3' ) .on('click' ,function() {

//方法一if(this.checked==true) {

$('#check31,#check32,#check33,#check34' ) .prop('checked' , true) ;}else{

$('#check31,#check32,#check33,#check34' ) .prop('checked' ,false) ;}

//方法二如上

} ) ;

/****----第四行----****/

$('#checkh4' ) .on('click' ,function() {

//方法一if(this.checked==true) {

$('#check41,#check42,#check43,#check44' ) .prop('checked' , true) ;}else{

$('#check41,#check42,#check43,#check44' ) .prop('checked' ,false) ;}

//方法二如上

} ) ;

/****----第五行----****/

$('#checkh5' ) .on('click' ,function() {

//方法一if(this.checked==true) {

$('#check51,#check52,#check53,#check54' ) .prop('checked' , true) ;}else{

$('#check51,#check52,#check53,#check54' ) .prop('checked' ,false) ;}

//方法二如上

} ) ;

} ) ;

</script>

</head>

<body>

<table style="width:50%;">

<tr>

<td><input type="checkbox" id = "check1" /><label for="check1"class="do">全选</label></td>

<td><input type="checkbox" id = "checkl1" /><label for="checkl1">第一列</label></td>

<td><input type="checkbox" id = "checkl2" /><label for="checkl2">第二列</label></td>

<td><input type="checkbox" id = "checkl3" /><label for="checkl3">第三列</label></td>

<td><input type="checkbox" id = "checkl4" /><label for="checkl4">第四列</label></td>

</tr>

<tr>

<td><input type="checkbox" id = "checkh1" /><label for="checkh1">第一行</label></td>

<td><input type="checkbox" id = "check11" /></td>

<td><input type="checkbox" id = "check12" /></td>

<td><input type="checkbox" id = "check13" /></td>

<td><input type="checkbox" id = "check14" /></td>

</tr>

<tr>

<td><input type="checkbox" id = "checkh2" /><label for="checkh2">第二行</label></td>

<td><input type="checkbox" id = "check21" /></td>

<td><input type="checkbox" id = "check22" /></td>

<td><input type="checkbox" id = "check23" /></td>

<td><input type="checkbox" id = "check24" /></td>

</tr>

<tr>

<td><input type="checkbox" id = "checkh3" /><label for="checkh3">第三行</label></td>

<td><input type="checkbox" id = "check31" /></td>

<td><input type="checkbox" id = "check32" /></td>

<td><input type="checkbox" id = "check33" /></td>

<td><input type="checkbox" id = "check34" /></td>

</tr>

<tr>

<td><input type="checkbox" id = "checkh4" /><label for="checkh4">第四行</label></td>

<td><input type="checkbox" id = "check41" /></td>

<td><input type="checkbox" id = "check42" /></td>

<td><input type="checkbox" id = "check43" /></td>

<td><input type="checkbox" id = "check44" /></td>

</tr>

<tr>

<td><input type="checkbox" id = "checkh5" /><label for="checkh5">第五行</label></td>

<td><input type="checkbox" id = "check51" /></td>

<td><input type="checkbox" id = "check52" /></td>

<td><input type="checkbox" id = "check53" /></td>

<td><input type="checkbox" id = "check54" /></td>

</tr>

</tbody>

</table>

</body>

</html>

效果图

以上所述是小编给大家介绍的checkbox选中一个另一个checkbox也会选中的实现代码的全部叙述希望对大家有所帮助如果大家想了解更多内容敬请关注脚本之家

百纵科技(19元/月),美国洛杉矶10G防御服务器/洛杉矶C3机房 带金盾高防

百纵科技官网:https://www.baizon.cn/百纵科技:美国云服务器活动重磅来袭,洛杉矶C3机房 带金盾高防,会员后台可自助管理防火墙,添加黑白名单 CC策略开启低中高.CPU全系列E52680v3 DDR4内存 三星固态盘列阵。另有高防清洗!美国洛杉矶 CN2 云服务器CPU内存带宽数据盘防御价格1H1G10M10G10G19元/月 购买地址2H1G10M10G10G29元/月 购买...

ftlcloud9元/月,美国云服务器,1G内存/1核/20g硬盘/10M带宽不限/10G防御

ftlcloud(超云)目前正在搞暑假促销,美国圣何塞数据中心的云服务器低至9元/月,系统盘与数据盘分离,支持Windows和Linux,免费防御CC攻击,自带10Gbps的DDoS防御。FTL-超云服务器的主要特色:稳定、安全、弹性、高性能的云端计算服务,快速部署,并且可根据业务需要扩展计算能力,按需付费,节约成本,提高资源的有效利用率。活动地址:https://www.ftlcloud.com...

PacificRack 下架旧款方案 续费涨价 谨慎自动续费

前几天看到网友反馈到PacificRack商家关于处理问题的工单速度慢,于是也有后台提交个工单问问,没有得到答复导致工单自动停止,不清楚商家最近在调整什么。而且看到有网友反馈到,PacificRack 商家的之前年付低价套餐全部下架,而且如果到期续费的话账单中的产品价格会涨价不少。所以,如果我们有需要续费产品的话,谨慎选择。1、特价产品下架我们看到他们的所有原来发布的特价方案均已下架。如果我们已有...

checkbox选中为你推荐
北京市通州区教育委员会Max163设备ipad支持ipad责任编辑:纪春ms17-010win10蒙林北冬虫夏草酒·10年原浆1*6 500ml 176,176是一瓶的价格还是一箱的价格重庆电信宽带管家重庆电信宽带安装收费谷歌sb为什么搜索SB第一个是google?迅雷快鸟迅雷快鸟是做什么用的,,,win7关闭135端口如何关闭135端口,关闭它有什么影响么?
域名空间注册 便宜虚拟主机 双线服务器租用 南通服务器租用 google镜像 缓存服务器 国外bt 标准机柜尺寸 网通服务器ip 嘟牛 java虚拟主机 e蜗 最好的免费空间 静态空间 丽萨 dnspod 国外的代理服务器 万网空间 测试网速命令 godaddy空间 更多