zoukankan      html  css  js  c++  java
  • 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[i].checked=oper;
    break;
    case 0:
    arr[i].checked=oper;
    break;
    case -1:
    arr[i].checked=! arr[i].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="全选"  onclick="select1(1)" />
    <input type="button" value="反选"  onclick="select1(-1)" />
    <input type="button" value="取消"  onclick="select1(0)" />
    </body>
    </html>
    
  • 相关阅读:
    为什么转速环经过pi调节后输出的是电流?
    如何将mysql、php、nginx设置为开机自启动
    rm-rf /*
    2020/4/23-linux中的定时任务详解
    2020/4/20 一键部署服务
    2020/4/20-ansible一键部署nfs
    2020/4/20-backup之rsync
    2020/4/19-linux中/etc/hosts
    2020/4/18-linux中的selinux
    2020/4/18-linux中的iptables
  • 原文地址:https://www.cnblogs.com/ZhangYuLIng/p/4324652.html
Copyright © 2011-2022 走看看