zoukankan      html  css  js  c++  java
  • event chrome firefox 获取点击对象的 id 类

    <!doctype html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">
    </head>
    <body>
    <p onclick="e0()" id="id0" class="class0">e0</p><br>
    <p onclick="e1()" id="id1" class="class1">e1</p>
    </body>
    </html>
    <script>
    function e0(){
    c(event);
    }
    function e1(){
    var event = window.event
    c(event);
    }
    function c(e){
    console.log('--->');
    console.log(e);
    console.log(e.target);
    console.log(e.target.getAttribute('id'));
    console.log(e.target.getAttribute('class'));
    }
    </script>

    https://developer.mozilla.org/en-US/docs/Web/API/Event

    1. MDN
    2.  
    3. Web technology for developers
    4.  
    5. Web APIs
    6.  
    7. Event

    The Event interface represents any event which takes place in the DOM; some are user-generated (such as mouse or keyboard events), while others are generated by APIs (such as events that indicate an animation has finished running, a video has been paused, and so forth). There are many types of event, some of which use are other interfaces based on the main Event interface. Event itself contains the properties and methods which are common to all events.

  • 相关阅读:
    day74test
    day73
    drf节流
    drf面试题及总结
    day72test
    日常积累
    windows 内核下获取进程路径
    转:浅析C++中的this指针
    vc 获取窗口标题GetWindowText
    驱动自定义回调例程
  • 原文地址:https://www.cnblogs.com/rsapaper/p/6489731.html
Copyright © 2011-2022 走看看