<html>
<head></head>
<body>
<div id="places">
<input type="checkbox" name="chx" value="1" onclick="_check_status(this)"/>香港
<input type="checkbox" name="chx" value="2" onclick="_check_status(this)"/>澳门
<input type="checkbox" name="chx" value="3" onclick="_check_status(this)"/>深圳
<input type="checkbox" name="chx" value="4" onclick="_check_status(this)"/>台北
<input type="checkbox" name="chx" value="5" onclick="_check_status(this)"/>乌镇
</div> <div id="allplaces">
<input type="checkbox" id="checkall" name="chx" value="0" onclick="_check_all(this)"/>全选
</div>
</body>
<script>
//点击“全选”, 所有地方都选上
function _check_all(obj)
{
var nodes = document.getElementById("places").childNodes;
if(obj.checked)
{
for (var i=0; i < nodes.length; i++)
{
if(nodes[i].type == "checkbox")
{
nodes[i].checked = true;
}
}
}
else
{
for (var i=0; i < nodes.length; i++)
{
if(nodes[i].type == "checkbox")
{
nodes[i].checked = false;
}
}
}
} //每一个checkbox的状态校验
function _check_status(obj)
{
var nodes = document.getElementById("places").childNodes;
if(obj.checked)
{
for (var i=0; i < nodes.length; i++)
{
if((nodes[i].type == "checkbox") && !nodes[i].checked)
{
document.getElementById("checkall").checked = false;
return;
}
} document.getElementById("checkall").checked = true;
}
else
{
document.getElementById("checkall").checked = false;
}
} </script>
</html>

最新文章

  1. asp.net MVC 应用程序的生命周期
  2. getopt()和getopt_long()用法
  3. myeclipse下构建maven web项目
  4. Swift游戏实战-跑酷熊猫 08 产生源源不断的移动平台
  5. Winform_ComBox三种赋值方式
  6. lstm-思想2
  7. Sublime Text3 个人使用心得
  8. SQL server聚合函数、数学函数、字符串函数
  9. (转)C++静态库与动态库
  10. STM32F051 IAP源代码分享
  11. HTML中发送方式(method)中get和post的比较
  12. ZOJ 1530 - Find The Multiple
  13. Composer简介及使用实例
  14. margin:0 auto是什么意思
  15. centos7安装zabbix4.2
  16. 20155227《网络对抗》Exp3 免杀原理与实践
  17. 关于Unity中3D声音的使用
  18. 12月6日 看Active Record validation ; 做jdstore ,注意gem bootstrap 版本只支持bootstrap3。
  19. Python的hasattr() getattr() setattr() 函数使用方法
  20. 48位MAC转化为唯一的128位IPV6地址

热门文章

  1. 【找规律】【DFS】XVII Open Cup named after E.V. Pankratiev Stage 14, Grand Prix of Tatarstan, Sunday, April 2, 2017 Problem A. Arithmetic Derivative
  2. 【AC自动机】HDU中模板题
  3. Nginx简单认识
  4. HDU 4417 Super Mario(划分树)
  5. 推荐一篇讲arm架构gcc内联汇编的文章
  6. jquery-qrcode 生成和读取二维码
  7. 扩展 jQuery datebox控件按钮
  8. java发送http的get和post请求
  9. python中在ubuntu中安装虚拟环境及环境配置
  10. HDU 4372 - Count the Buildings(组合计数)