zoukankan      html  css  js  c++  java
  • JavaScript

    <body>
            <input type="checkbox"  onmouseover="document.getElementById('div1').style.display = 'block'" onmouseout="document.getElementById('div1').style.display='none'"/>
            <div id = "div1">
                for your information safety...
            </div>
        </body>

    onmouseover,onmouseout

    onmouseover = "document.getElementById('div1').style.display = 'block' ";

    <body>
        <div id="div1" onmouseover="ToGreen()" onmouseout="ToRed()">
    
        </div>
    </body>
    <script>
            function ToGreen() {
                var oDiv = document.getElementById('div1');
                oDiv.style.width = '300px';
                oDiv.style.height = '300px';
                oDiv.style.background = 'green';
            }
            function ToRed() {
                var oDiv = document.getElementById('div1');
                oDiv.style.width = '200px';
                oDiv.style.height = '200px';
                oDiv.style.background = 'red';
            }
        </script>

    关联到了函数

    onmouseover = "ToGreen ( ) ";

    var oDiv = document.getElementById('div1');//获取节点

    <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>
            <input type="checkbox" /><br>
            <input type="checkbox" /><br>
            <input type="checkbox" /><br>
        </div>
    </body>
    <script>
            var i;
            window.onload = function () {
                var Btn1 = document.getElementById('btn1');
                var Btn2 = document.getElementById('btn2');
                var Div1 = document.getElementById('div1');
                var cekb = Div1.getElementsByTagName('input');
                var Btn3 = document.getElementById('btn3');
                Btn1.onclick = function () {
                    for (i = 0; i < cekb.length; i++) {
                        cekb[i].checked = true;
                    }
                }
                Btn2.onclick = function () {
                    for (i = 0; i < cekb.length; i++) {
                        cekb[i].checked = false;
                    }
                }
                Btn3.onclick = function () {
                    for (i = 0; i < cekb.length; i++) {
                        if (cekb[i].checked == true) {
                            cekb[i].checked = false;
                        }
                        else {
                            cekb[i].checked = true;
                        }
                    }
                }
    
            }
        </script>

    window.onload  = function()

    {

    }

    Btn1.onclick = function () {
    for (i = 0; i < cekb.length; i++) {
    cekb[i].checked = true;
    }
    }
  • 相关阅读:
    OC3(字符串,值类)
    OC2(初始化方法)
    OC1(类和对象)
    postgresql 时间戳格式为5分钟、15分钟
    centos添加ftp用户并禁止外切目录
    postgresql 判断日期是否合法
    tigerVNC的简单使用教程(CentOS的远程桌面连接)
    linux awk解析csv文件
    由windows向linux上传下载文件方法
    codeblocks linux编译告警乱码解决办法
  • 原文地址:https://www.cnblogs.com/Artimis-fightting/p/10949633.html
Copyright © 2011-2022 走看看