zoukankan      html  css  js  c++  java
  • Example015实现html中checkbox的全选和反选(2)

    <!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>
    

      

  • 相关阅读:
    python学习day15 内置函数
    python学习day14 生成器表达式
    python学习day13 迭代器,生成器
    python学习day12 装饰器进阶
    gulp管理angular2项目 配置文件
    angular2 基于webpack环境搭建
    jQuery dataTable 操作个人使用总结
    报错:Could not reserve enough space for object heap error
    CSS布局之圣杯布局和双飞翼布局
    CSS 之 Position定位
  • 原文地址:https://www.cnblogs.com/handsomehan/p/5373128.html
Copyright © 2011-2022 走看看