zoukankan      html  css  js  c++  java
  • 事件绑定

    绑定多个事件

    <html>
        <head>
            <meta charset="UTF-8">
            <title></title>
            <style>
                #box1{
                    100px;
                    height:100px;
                    background: red;
                }
                #box2{
                    200px;
                    height:200px;
                    background: blue;
                }
            </style>
            <script>
                        function addEvent(obj,ev,fn){
                                if(obj.attachEvent){obj.attachEvent('on'+ev,fn);
                                }else{obj.addEventListener(ev,fn,false)}
                            }
                     window.onload=function(){
                              var oBox1=document.getElementById("box1");
                              var oBox2=document.getElementById("box2");
                              addEvent(oBox1,'click',function(){
                                 oBox2.style.background='green';
                              });
                              addEvent(oBox1,'mouseover',function(){
                                 this.style.background='purple';
                              });
                              addEvent(oBox1,'mouseout',function(){
                                 this.style.background='red';
                              });
                }
            </script>
        </head>
        <body>
            <div id="box1"></div>
            <div id="box2"></div>
        </body>
    </html>
  • 相关阅读:
    php关联Apache和nginx
    /etc/profile
    snmp配置
    snmpwalk
    redis主从
    redis安装
    计算真实可用内存
    分类样本不均
    pandas apply 添加进度条
    linux 单次定时任务
  • 原文地址:https://www.cnblogs.com/yang0902/p/5703763.html
Copyright © 2011-2022 走看看