abstract:<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>全选按钮的实现</title> <style type="text/css"> .box{width: 80px;h
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>全选按钮的实现</title> <style type="text/css"> .box{width: 80px;height: 200px;border: 1px solid #000;margin: 0 auto;} .box div{border-bottom: 1px solid #666;margin-bottom: 8px;line-height: 30px;height: 30px;} .box input{margin-top: 8px;} </style> <script type="text/javascript"> function checkall(){ var all,item; all=document.getElementById('checkall') item=document.getElementsByName("item[]") for ( var i = 0; i <item.length; i++) { if (all.checked) { item[i].checked=true; }else{ item[i].checked=false; } } } </script> </head> <body> <div > <div> <input type="checkbox" id="checkall" onclick="checkall()">全选 </div> <input type="checkbox" name="item[]">选项1<br> <input type="checkbox" name="item[]">选项2<br> <input type="checkbox" name="item[]">选项3<br> <input type="checkbox" name="item[]">选项4<br> <input type="checkbox" name="item[]">选项5<br> <input type="checkbox" name="item[]">选项6 </div> </body> </html>
中间犯了一个低级错误,将函数方法名与函数内的变量设置成同一个名称,导致函数不生效,以后会多加注意的
Correcting teacher:查无此人Correction time:2019-03-09 09:21:17
Teacher's summary:完成的不错。代码记得缩进,看着整齐。 每行jis语句后面要增加结束符; 继续加油