zoukankan      html  css  js  c++  java
  • 封装事件框架

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Document</title>
        <style>
            div{
                 100px;
                height: 100px;
                background: red;
            }
        </style>
    </head>
    <body>
    <button id="btn">按钮</button>
    <div id='div'></div>
    </body>
    <script src='itcast.js'></script>
    <script type="text/javascript">
    
        //测试
        $$.event.click('btn', function(){
            document.getElementsByTagName('div')[0].style.background = 'green'
        });
    
        $$.event.mouseover('div', function(){
            this.style.background = 'blue'
        });
    
        $$.event.mouseout('div', function(){
            this.style.background = 'pink'
        });
    
    </script>
    </html>

    使用 extend 改造

    $$.hover('div'   ,   function(){  }  ,  function(){  } ) ;

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Document</title>
        <style>
            div{
                 100px;
                height: 100px;
                background: red;
            }
        </style>
    </head>
    <body>
    <button id="btn">按钮</button>
    <div id='div'></div>
    </body>
    <script src='itcast2.js'></script>
    <script type="text/javascript">
    
        //测试
        $$.click('btn', function(){
            document.getElementsByTagName('div')[0].style.background = 'green'
        });
    
        $$.hover('div', function(){                    
            this.style.background = 'blue'
        },function(){
            this.style.background = 'pink'
        });
    
    </script>
    </html>
  • 相关阅读:
    【NOIP2017】蚯蚓
    【CF407B】Long Path
    【NOIP2017】奶酪
    【NOIP2018】赛道修建(正解)
    【NOIP2018】旅行
    【SDOI2010】地精部落
    【NOIP2017】逛公园
    百度云网盘进行注销操作
    百度超级会员租借.我租给你。
    如何在dos中运行java中的jar包
  • 原文地址:https://www.cnblogs.com/shanlu0000/p/11605191.html
Copyright © 2011-2022 走看看