<br><div class="codetitle"> <span><a style="CURSOR: pointer" data="29621" class="copybut" id="copybut29621" onclick="doCopy('code29621')"><u>复制代码</u></a></span> 代码如下:</div> <div class="codebody" id="code29621"> <br><div id="div1"> <br><input type="checkbox" onclick="selectCheckBoxes('div1', this.checked)">全选<br> <br><input type="checkbox"><br> <br><input type="checkbox"><br> <br><input type="checkbox"><br> <br> </div> <br><br> <br><div id="div2"> <br><input type="checkbox" onclick="selectCheckBoxes('div2', this.checked)">全选<br> <br><input type="checkbox"><br> <br><input type="checkbox"><br> <br><input type="checkbox"><br> <br> </div> <br> </div> <br><!--js代码片段如下: --> <br><div class="codetitle"> <span><a style="CURSOR: pointer" data="21335" class="copybut" id="copybut21335" onclick="doCopy('code21335')"><u>复制代码</u></a></span> 代码如下:</div> <div class="codebody" id="code21335"> <br><script type="text/javascript"> <BR>function selectCheckBoxes(domId,value) { <BR>var inputs = document.getElementById(domId).getElementsByTagName("input"); <BR>for(var i = 0; i < inputs.length; i++) { <BR>if (inputs[i].type == 'checkbox') { <BR>inputs[i].checked=value; <BR>} <BR>} <BR>} <BR></script> <br> </div> <br>将以上代码放到body里即可。