日期:2014-05-17 浏览次数:20751 次
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>全选或其全不选</title> <script language="javascript"> function checkAll() { var allCheckBoxs=document.getElementsByName("isBuy"); for(var i = 0; i<allCheckBoxs.length;i++) { if(allCheckBoxs[i].type="checkbox") { if(allCheckBoxs[i].checked==true){ allCheckBoxs[i].checked=false; }else if(allCheckBoxs[i].checked==false){ allCheckBoxs[i].checked=true; } } } } </script> </head> <body> <a href="javascript:checkAll(true)">全选</a> <a href="javascript:checkAll(false)">全不选</a> <input type="checkbox" name="" onclick="javascript:checkAll()">全选 <table width="250" height="194" border="0"> <tr> <td width="105"> <input type="checkbox" name="isBuy" /> </td> <td width="129" colspan="2">张三</td> </tr> <tr> <td width="105"> <input type="checkbox" name="isBuy" /></td> <td width="129" colspan="2">李四</td> </tr> <tr> <td width="105" > <input type="checkbox" name="isBuy"/></td> <td width="129" colspan="2">王麻子</td> </tr> <td width="105"> <input type="checkbox" name="isBuy"/></td> <td width="129" colspan="2">赵六</td> </tr> </table> </body> </html>