<html> <head> <style> li{list-style-type:none;} </style> <script> document.write("<ul>"); for(var i=0;i<10;i++){ document.write("<li>"); document.write("下一个天亮"); document.write("<input type='checkbox' name='ck' value=''>"); document.write("</li>"); } document.write("</ul>"); var ip=document.getElementsByName('ck'); function soul(){ var ip=document.getElementsByName('ck'); for(var j=0;j<ip.length;j++){ ip[j].checked=true; } } function qk(){ for(var j=0;j<ip.length;j++){ ip[j].checked=false; } } function revers(){ for(var j=0;j<ip.length;j++){ if(ip[j].checked==true){ ip[j].checked=false; }else{ ip[j].checked=true; } } } function del(){ for(var j=0;j<ip.length;j++){ if(ip[j].checked==true){ ip[j].parentNode.style.display="none"; } } } </script> </head> <body> <input type="button" value="全选" onClick="soul()"> <input type="button" value="清空" onClick="qk()"> <input type="button" value="反选" onClick="revers()"> <input type="button" value="删除" onClick="del()"> </body> </html> |