两种不同的方法实现js对checkbox进行全选和反选
时间:2024-04-10 16:14:50
通过两种不同的方法实现用js来对checkbox进行全选和反选:
方法一:
1:js实现checkbox的 全选 功能:
function checkAll()
{
var code_Values = document.getElementsByTagName("input");
for(i = 0;i < code_Values.length;i++){
if(code_Values[i].type == "checkbox")
{
code_Values[i].checked = true;
}
}
}
2:js实现checkbox的 反选 功能:
function uncheckAll()
{
var code_Values = document.getElementsByTagName("input");
for(i = 0;i < code_Values.length;i++){
if(code_Values[i].type == "checkbox")
{
code_Values[i].checked = false;
}
}
}
标签:checkbox,全选,反选
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
Python中遍历列表的方法总结
2023-11-01 19:11:11
浅析Python面向对象编程
2023-11-23 07:52:12
Python中如何导入类示例详解
2023-05-09 08:35:58
Python简单生成随机数的方法示例
2021-01-21 02:30:37
Python使用Selenium实现淘宝抢单的流程分析
2022-01-31 04:04:18
![](https://img.aspxhome.com/file/2023/4/68894_0s.png)
使用python将图片按标签分入不同文件夹的方法
2021-04-14 05:34:54
![](https://img.aspxhome.com/file/2023/6/118716_0s.jpg)
PHP+Mysql基于事务处理实现转账功能的方法
2023-10-21 16:53:06
MySQL高可用架构之MHA架构全解
2024-01-25 03:15:23
![](https://img.aspxhome.com/file/2023/4/111364_0s.png)
Go语言如何使用golang-jwt/jwt/v4进行JWT鉴权详解
2024-02-07 05:13:41
![](https://img.aspxhome.com/file/2023/7/105147_0s.jpg)
python 下载文件的多种方法汇总
2023-08-11 16:50:05
![](https://img.aspxhome.com/file/2023/7/105017_0s.gif)
使用go module导入本地包的方法教程详解
2024-03-26 01:44:43
SQL Server数据库连接查询的种类及其应用
2009-01-06 11:28:00
Python 绘制可视化折线图
2023-08-25 18:12:14
![](https://img.aspxhome.com/file/2023/3/128213_0s.jpg)
教程:MySQL中多表操作和批处理方法
2009-07-30 08:20:00
SQL server使用自定义函数以及游标
2024-01-23 23:55:32
小程序自定义弹出框效果
2023-07-02 03:47:33
![](https://img.aspxhome.com/file/2023/4/136124_0s.jpg)
网站设计配色方案教程
2007-10-10 19:38:00
![](https://img.aspxhome.com/file/UploadPic/up/2007101019571461.jpg)
Python实现随机划分图片数据集的示例代码
2021-08-01 16:35:32
Mysql主键和唯一键的区别点总结
2024-01-15 10:36:36
![](https://img.aspxhome.com/file/2023/5/128385_0s.jpg)
关于js遍历表格的实例
2024-04-18 09:29:21