How to find event listeners on a DOM node when debugging or from the JavaScript code?

前端 未结 19 2568
臣服心动
臣服心动 2020-11-21 05:34

I have a page where some event listeners are attached to input boxes and select boxes. Is there a way to find out which event listeners are observing a particular DOM node a

19条回答
  •  面向向阳花
    2020-11-21 06:08

    Prototype 1.7.1 way

    function get_element_registry(element) {
        var cache = Event.cache;
        if(element === window) return 0;
        if(typeof element._prototypeUID === 'undefined') {
            element._prototypeUID = Element.Storage.UID++;
        }
        var uid =  element._prototypeUID;           
        if(!cache[uid]) cache[uid] = {element: element};
        return cache[uid];
    }
    

提交回复
热议问题