日期:2014-05-17 浏览次数:20709 次
<html> <head> <script> function checkAll(obj) { var checkboxs = document.getElementsByName("checkA"); if(checkboxs) { for(var i = 0; i < checkboxs.length; i++) { var cb = checkboxs[i]; cb.checked = obj.checked; } } } </script> </head> <body> <h1>全选/全不选</h1> <table border="1"> <tr> <td><input type="checkbox" name="checkAll" onclick="checkAll(this);"></td> <td width="120px"></td> </tr> <tr> <td><input type="checkbox" name="checkA"></td> <td>选择1</td> </tr> <tr> <td><input type="checkbox" name="checkA"></td> <td>选择2</td> </tr> <tr> <td><input type="checkbox" name="checkA"></td> <td>选择3</td> </tr> <tr> <td><input type="checkbox" name="checkA"></td> <td>选择4</td> </tr> </table> </body> </html>