<div class="codetitle"> <span><a style="CURSOR: pointer" data="44677" class="copybut" id="copybut44677" onclick="doCopy('code44677')"><u>复制代码</u></a></span> 代码如下:</div> <div class="codebody" id="code44677"> <br> <br> <br><title>制作全选效果</title> <br><script language="javascript"> <BR>function selectAll(){ <BR>allcheckBoxs=document.getElementsByName("a"); <BR>var a2=document.getElementsByName("a1"); <BR>if(a2[0].checked){ <BR>for(var i=0;i<allcheckBoxs.length;i++){ <BR>allcheckBoxs[i].checked = true; <BR>} <BR>}else{ <BR>for(var i=0;i<allcheckBoxs.length;i++){ <BR>allcheckBoxs[i].checked = false; <BR>} <BR>} <BR>} <BR></script> <br> <br> <br><form name="myform"> <br><table> <br><tr><td colspan="2"><img src="images/head.jpg" alt="通过js来制作复选框的全选和不选效果_javascript技巧" ></td></tr> <br><tr> <br><td> <input type="checkbox" name="a1" onclick="selectAll()">全选/全不选</td> <br><td> <img src="images/top.jpg" alt="通过js来制作复选框的全选和不选效果_javascript技巧" > </td> <br> </tr> <br><tr> <td><input type="checkbox" name="a"></td> <td><img src="images/one.jpg" alt="通过js来制作复选框的全选和不选效果_javascript技巧" ></td> </tr> <br><tr> <td><input type="checkbox" name="a"></td> <td><img src="images/two.jpg" alt="通过js来制作复选框的全选和不选效果_javascript技巧" ></td> </tr> <br><tr> <td><input type="checkbox" name="a"></td> <td><img src="images/three.jpg" alt="通过js来制作复选框的全选和不选效果_javascript技巧" ></td> </tr> <br><tr> <td><input type="checkbox" name="a"></td> <td><img src="images/four.jpg" alt="通过js来制作复选框的全选和不选效果_javascript技巧" ></td> </tr> <br> </table> <br> </form> <br> <br> <br> </div>