zoukankan      html  css  js  c++  java
  • JS鼠标的常用事件

     1 <!DOCTYPE html>
     2 <html>
     3     <head>
     4         <meta charset="utf-8">
     5         <title></title>
     6     </head>
     7     <body>
     8         <button id="btn">双击1</button>
     9         <button ondblclick="c()">双击2</button>
    10         <button onclick="a(this.innerText);b(event)">点击</button>
    11         <script type="text/javascript">
    12             a = (s) => console.log(s)
    13             b = (e) => {
    14                 console.log(e);
    15                 e.target.style.fontSize = '20px'
    16             }
    17             c = () => alert('双击鼠标事件');
    18             let btn = document.getElementsByTagName('button')
    19             btn[1].onmouseover = ()=> console.log('鼠标移入button');
    20             btn[1].onmouseout = () => console.log('鼠标移出button');
    21             // addEventListener:为指定对象添加事件
    22             document.getElementById('btn').addEventListener('dblclick',function () {
    23                 alert('双击鼠标事件')
    24             })
    25             // 新建一个div
    26             let add = document.createElement('div')
    27             console.log(add)
    28             // 添加css
    29             add.innerText = '这是测试';
    30             add.style.fontSize = '20px';
    31             add.style.color = 'red';
    32             // 将新建的div添加值body里
    33             document.body.appendChild(add)
    34             // 打印document的结构
    35             console.log(document)
    36         </script>
    37     </body>
    38 </html>
  • 相关阅读:
    Live2D 看板娘
    Live2D 看板娘
    python框架☞Flask
    Python框架☞Django
    Python ORM框架之SQLALchemy
    HTTP1.0 HTTP 1.1 HTTP 2.0主要区别
    【F12】修改 DevTools的主题
    【F12】网络面板
    【正在等待可用套接字】解决方法
    nginx反向代理压测问题记录
  • 原文地址:https://www.cnblogs.com/lyt520/p/13454491.html
Copyright © 2011-2022 走看看