js全选反选按钮实现
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>
</title>
</head>
<body>
<form action="">
<p><input type="checkbox" >我是谁</p>
<p><input type="checkbox" >我在哪</p>
<p><input type="checkbox" >我在做什么呢</p>
<p><input type="checkbox" >你知道</p>
<p><input type="checkbox" >我不知道</p>
</form>
<p>
<button id="all">全选</button>
<button id="notall">全不选</button>
<button id="unall">反选</button>
</p>
<script>
var all =document.getElementById('all');
var notall=document.getElementById('notall');
var unall=document.getElementById('unall');
var inputs =document.getElementsByTagName('input');
all.onclick=function(){
for(var i=0;i<inputs.length;i++){
inputs[i].checked=true;
}
}
notall.onclick=function(){
for(var i=0;i<inputs.length;i++){
inputs[i].checked=false;
}
}
unall.onclick=function(){
for(var i=0;i<inputs.length;i++){
inputs[i].checked = !inputs[i].checked;
}
}
</script>
</body>
</html>
最新文章
- Ubuntu 部署 Node.js 应用
- mysql延迟查询, 覆盖索引使用例子
- C#中使用System.Web.Mail.MailMessage类无法CC多人的问题
- 使用ASP.Net WebAPI构建REST服务(一)——简单的示例
- 四个查找命令find,locate,whereis,which的区别
- Oracle逻辑读详解
- 由12306出错想到的div垂直居中的问题
- arcgis for android访问arcgis server上自己制作部署的地图服务
- android应用程序的优先级
- python np.linspace
- 授权(Authorization)
- C# 窗体靠近屏幕边缘自动隐藏*学习(类似于QQ)
- web开发 关于src跳转
- git常用命令<;转>;
- Visual Studio 继续并运行上次的成功生成,未提示直接运行上一个版本解决方案!
- 【原】vue单文件组件互相通讯
- java Properties类得到当前的系统属性
- 如何用Python在豆瓣中获取自己喜欢的TOP N电影信息
- (一)JUnit简介
- 11-Cookie&;Session
热门文章
- 网络project1101班2014-2015学年《网络软件开发实训》期末考试
- 【HDU 5402】Travelling Salesman Problem(构造)
- Function的一些结论与eval函数.
- Linux 终端仿真程序Putty
- 利用Python网络爬虫抓取微信好友的签名及其可视化展示
- linux下,yum 安装mysql
- CSUOJ 1651 Weirdo
- P2186 小Z的栈函数
- [Python] Find available methods and help in REPL
- Fastboot线刷“复活”之刷机心得(三)——错误处理