javascript的DOM学习上
<!doctype html> <html> <head> <meta charset="utf-8"/> </head> <body> <script> for(var i=0;i<10;i++) { document.write("<li><input type='checkbox' name='select[]'>"+i+"aaaaaaaaaaaaaaaaaa</li>") } var select=document.getElementsByName("select[]"); var sall=document.getElementsByName("sall"); function all() { for(var i=0;i<select.length;i++) { select[i].checked="true"; } } function fall() { for(var i=0;i<select.length;i++) { if(select[i].checked) { select[i].checked=""; } else { select[i].checked="true"; } } } function nall() { for(var i=0;i<select.length;i++) { select[i].checked=""; } } function mall(a){ for(var i=0;i<select.length;i++) { select[i].checked=a.checked; } } </script> <a href="javascript:all()">全选</a> <a href="javascript:fall()">反选</a> <a href="javascript:nall()">全不选</a> <input type="checkbox" onclick="mall(this)"/>全选 </body> </html>
if you don't try,you will never know!