美文网首页
获取某个dom元素上面都绑定了哪些事件 包括addEventLi

获取某个dom元素上面都绑定了哪些事件 包括addEventLi

作者: cooqi | 来源:发表于2020-04-21 17:42 被阅读0次

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script>
            EVENT_LIST = new Array();
                        _addEventListener = Element.prototype.addEventListener;
                        Element.prototype.addEventListener = function(event,fn) {
                        EVENT_LIST.push({"event": event, "element": this})
                        console.log(EVENT_LIST,fn)
                        _addEventListener.apply(this, arguments);
            };
        </script>
</head>
<body>
    <div onclick="a()" id="test">123</div>
    <script>
        document.getElementById("test").addEventListener("click", function(){
            a();
        });
        function a(){
            alert(1)
        }
    </script>
</body>
</html>



相关文章

网友评论

      本文标题:获取某个dom元素上面都绑定了哪些事件 包括addEventLi

      本文链接:https://www.haomeiwen.com/subject/lmspihtx.html