首页 > Web开发 > 详细

Example015实现html中checkbox的全选和反选(2)

时间:2016-04-10 01:04:44      阅读:247      评论:0      收藏:0      [点我收藏+]
<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>实例015</title>
</head>
<body>
	<form>
		<label for="one"><input onclick="qx(this)" id="one" type="checkbox" >全选</label><br>

		<input type="checkbox" name="username[]" value="handsomehan">handsomehan<br>
		<input type="checkbox" name="username[]" value="handsomehan">handsomehan<br>
		<input type="checkbox" name="username[]" value="handsomehan">handsomehan<br>
		<input type="checkbox" name="username[]" value="handsomehan">handsomehan<br>
		<input type="checkbox" name="username[]" value="handsomehan">handsomehan<br>
		<input type="checkbox" name="username[]" value="handsomehan">handsomehan<br>
		<input type="checkbox" name="username[]" value="handsomehan">handsomehan<br>
		<input type="checkbox" name="username[]" value="handsomehan">handsomehan<br>
		<input type="checkbox" name="username[]" value="handsomehan">handsomehan<br>
		<input type="checkbox" name="username[]" value="handsomehan">handsomehan<br>
		<input type="checkbox" name="username[]" value="handsomehan">handsomehan<br>
		<input type="checkbox" name="username[]" value="handsomehan">handsomehan<br>
		<input type="checkbox" name="username[]" value="handsomehan">handsomehan<br>
		<input type="checkbox" name="username[]" value="handsomehan">handsomehan<br>
		<input type="checkbox" name="username[]" value="handsomehan">handsomehan<br>
		<input type="checkbox" name="username[]" value="handsomehan">handsomehan<br>
	</form>
	<script>
		var obj = document.getElementsByName("username[]");

		function qx(o) {
			for(var i = 0; i < obj.length; i ++) {
				obj[i].checked = o.checked;
			}
		}
	</script>
</body>
</html>

  

Example015实现html中checkbox的全选和反选(2)

原文:http://www.cnblogs.com/handsomehan/p/5373128.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!