日期:2014-05-17 浏览次数:20352 次
<html> <body> <script> document.write("<ul>"); for(var i=0;i<20;i++){ document.write("<li>"); document.write('<input type="checkbox" name="arr[]" value="'+i+'"> heihei'); document.write("</li>"); } document.write("</ul>"); </script> <input id="ss" type="checkbox" onclick="all(this)">全选 <script> var cnames=document.getElementsByName("arr[]"); alert(cnames.length); function all(obj){ for(var i=0;i<cnames.length;i++) { cnames[i].checked=obj.checked; } } </script> </body> </html>