javawangli 发表于 2013-2-7 18:57:09

javascript实现全选,反选及全不选

javascript实现全选,反选及全部选
  html 代码:
  
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312" /><title>无标题文档</title><script language="javascript">      function select1(oper){var arr= document.getElementsByName("fav");   for(var i=0;i<arr.length;i++){      switch(oper){case 1:   arr.checked=oper;    break;   case 0:arr.checked=oper;   break;   case -1: arr.checked=! arr.checked;       break;      }         }}</script></head><body>      <input type="checkbox" name="fav"value="吃饭"/>吃放    <input type="checkbox" name="fav"value="吃饭2"/>吃放2      <input type="checkbox" name="fav"value="吃饭3"/>吃放3      <input type="checkbox" name="fav"value="吃饭4"/>吃放5      <input type="checkbox" name="fav"value="吃饭6"/>吃放6      <input type="checkbox" name="fav"value="吃饭7"/>吃放7      <input type="checkbox" name="fav"value="吃饭8"/>吃放8       <input type="button" value="全选"   />   <input type="button" value="反选"   />   <input type="button" value="取消"   />   </body></html> 
页: [1]
查看完整版本: javascript实现全选,反选及全不选