zoukankan      html  css  js  c++  java
  • js中的全选,不选,和反选按钮的设定

    <!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=utf-8" />
    <title>无标题文档</title>
    <script>
    window.onload=function()
    {
        var obtn1=document.getElementById("btn1");
        var obtn2=document.getElementById("btn2");
        var obtn3=document.getElementById("btn3");
        var odiv=document.getElementById("div1");
        var ach=odiv.getElementsByTagName("input");
        obtn1.onclick=function()
        {
            for(i=0;i<ach.length;i++)
            {
                ach[i].checked=true;
            }
        }
        obtn2.onclick=function()
        {
            for(i=0;i<ach.length;i++)
            {
                ach[i].checked=false;
            }
        }
        obtn3.onclick=function()
        {
            for(i=0;i<ach.length;i++)
            {
                if(ach[i].checked==true)//注意if里面的==等号不能和赋值号=混淆
                {
                    ach[i].checked=false;
                }
                else
                {
                    ach[i].checked=true;
                }    
            }
        }
    }
    </script>
    </head>
    
    <body>
    <input  id="btn1" type="button" value="全选"  /></br>
    <input  id="btn2" type="button" value="不选"  /></br>
    <input  id="btn3" type="button" value="反选"  /></br>
    <div id="div1">
            <input type="checkbox"/></br>
            <input type="checkbox"/></br>
            <input type="checkbox"/></br>
            <input type="checkbox"/></br>
            <input type="checkbox"/></br>
            <input type="checkbox"/></br>
            <input type="checkbox"/></br>
            <input type="checkbox"/></br>
    </div>
    </body>
    </html>
        
  • 相关阅读:
    全文检索Lucene框架---分词器
    全文检索框架---Lucene
    Selenium问题总结
    monkey基本命令参数详解示例
    adb opendir failed ,permission denied
    VS调用python方法
    windows下使用pthread
    代码静态分析工具——splint的学习与使用
    三种方案在Windows系统下安装ubuntu双系统
    Ubuntu下载及安装
  • 原文地址:https://www.cnblogs.com/kangshuai/p/4669369.html
Copyright © 2011-2022 走看看