<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<span style="font-size: 24px;">javascript 案例 全选 不选 反选</span><br />
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>全选 不选 反选</title>
</head>
<script>
window.onload=function (){ var oBtn1=document.getElementById("Btn1");
var oBtn2=document.getElementById("Btn2");
var oBtn3=document.getElementById("Btn3");
var oDiv=document.getElementById("Ben");
var oInp=oDiv.getElementsByTagName("input"); oBtn1.onclick=function(){ //全选
//oInp[0].checked=true; // checked : 布尔值 false true;
for(var i=0; i<oInp.length ; i++){
oInp[i].checked=true;
}
};
oBtn2.onclick=function(){ //不选
for(var i=0; i<oInp.length ; i++){
oInp[i].checked=false;
}
};
oBtn3.onclick=function(){ //反选
for(var i=0; i<oInp.length ; i++){
if(oInp[i].checked==true){ oInp[i].checked=false;
}
else{
oInp[i].checked=true;
}
}
};
}; </script>
<body>
<input id="Btn1" type="button" value="全选" /><br />
<input id="Btn2" type="button" value="不选" /><br />
<input id="Btn3" type="button" value="反选" /><br />
<div id="Ben">
<input type="checkbox" /><br />
<input type="checkbox" /><br /> <!--复选框 checked 选中-->
<input type="checkbox" /><br />
<input type="checkbox" /><br />
<input type="checkbox" /><br />
<input type="checkbox" /><br />
<input type="checkbox" /><br />
<input type="checkbox" /><br />
<input type="checkbox" /><br />
<input type="checkbox" /><br />
<input type="checkbox" /><br />
<input type="checkbox" /><br />
</div> </body>
</html>

  

最新文章

  1. highcharts总结
  2. 适配ios10(iTunes找不到构建版本)
  3. iOS autoresizing布局
  4. ASP.Net MVC跳转,分为form的submit提交跳转和ajax跳转
  5. SYN Flood应如何应对
  6. Android系统下,用adb实现自动获取应用性能数据
  7. java基础:熟悉3种内部类的写法,重点匿名内部类的使用
  8. 【BZOJ】1014: [JSOI2008]火星人prefix(splay+hash+二分+lcp)
  9. 连接sql server数据库的两种方式
  10. 解决:cc1.exe: sorry, unimplemented: 64-bit mode not compiled in
  11. HTTP编程(六)
  12. C# Thread多线程学习
  13. 【IOS】在SDK中打开其他接入应用的解决方案
  14. Windows|Windows Server 2003单网卡搭建VPN
  15. 关于让simulink中display组件显示二进制的方法
  16. Confluence 6 管理应用服务器内存设置
  17. 一起用ipython
  18. MapReduce与关系型数据库的不同之处。
  19. 在项目中使用react
  20. vijos 1512 SuperBrother打鼹鼠

热门文章

  1. struts自定义拦截器实现
  2. 《编程导论(Java)&amp;#183;1.1.2 颠倒的世界(柏拉图法则)》
  3. linux c编程:popen
  4. android 中使用svg
  5. python实例1:创建一个登陆模块
  6. Kindeditor 编辑区样式结构
  7. simple -- abstract
  8. Python partial function 偏函数
  9. P4045 [JSOI2009]密码
  10. hihocoder #1032 : 最长回文子串【 manacher算法实现 】