<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> <title>製作全選效果</title> <br> <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>allcheckBoxs[i].checked = true; <br>} <br>}else{ <br>for(var i=0;i<allcheckboxs.length>allcheckBoxs[i].checked = false; <br>} <br>} <br>} <br>腳本> <br>頭> <br> <br> <br>; <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技巧" > <br> </td> </tr> <tr> <td><input type="checkbox" name="a"></td> <td><img src="images/%20Three.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>表> <br>表格> <br>身體> <br> <br><br></allcheckboxs.length></allcheckboxs.length> </div>