方法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也会选中的实现代码的全部叙述希望对大家有所帮助如果大家想了解更多内容敬请关注脚本之家

云基最高500G DDoS无视CC攻击(Yunbase),洛杉矶CN2GIA、国内外高防服务器

云基成立于2020年,目前主要提供高防海内外独立服务器用户,欢迎各类追求稳定和高防优质线路的用户。业务可选:洛杉矶CN2-GIA+高防(默认500G高防)、洛杉矶CN2-GIA(默认带50Gbps防御)、香港CN2-GIA高防(双向CN2GIA专线,突发带宽支持,15G-20G DDoS防御,无视CC)、国内高防服务器(广州移动、北京多线、石家庄BGP、保定联通、扬州BGP、厦门BGP、厦门电信、...

VirMach:$7.2/年KVM-美元512MB/$7.2/年MB多个机房个机房可选_双线服务器租赁

Virmach对资源限制比较严格,建议查看TOS,自己做好限制,优点是稳定。 vCPU 内存 空间 流量 带宽 IPv4 价格 购买 1 512MB 15GB SSD 500GB 1Gbps 1 $7/VirMach:$7/年/512MB内存/15GB SSD空间/500GB流量/1Gbps端口/KVM/洛杉矶/西雅图/芝加哥/纽约等 发布于 5个月前 (01-05) VirMach,美国老牌、稳...

可抵御99%的攻击中国单域版cdn:9元/月7T防御 cloudsecre

官方网站:点击访问CDN客服QQ:123008公司名:贵州青辞赋文化传媒有限公司域名和IP被墙封了怎么办?用cloudsecre.com网站被攻击了怎么办?用cloudsecre.com问:黑客为什么要找网站来攻击?答:黑客需要找肉鸡。问:什么是肉鸡?答:被控的服务器和电脑主机就是肉鸡。问:肉鸡有什么作用?答:肉鸡的作用非常多,可以用来干违法的事情,通常的行为有:VPN拨号,流量P2P,攻击傀儡,...

checkbox选中为你推荐
HALLMARK_PANCREAS_BETA_CELLSios11投标迅雷supplementedroute支出127functionscsscomputationgraphSinglesb支持ipadcss3圆角css实现圆角的几种方法是什么?重庆宽带测速重庆哪一种宽带网速最快
网站域名 万网域名注册 长沙域名注册公司 老左 台湾服务器 edis 免费个人空间 赞助 idc是什么 海外空间 路由跟踪 godaddy空间 apnic xshell5注册码 phpinfo 海外加速 2016黑色星期五 服务器操作系统 中国域名根服务器 网络安装 更多