111

I'd like to see all the events fired by an input field as a user interacts with it. This includes stuff like:

  1. Clicking on it.
  2. Clicking off it.
  3. Tabbing into it.
  4. Tabbing away from it.
  5. Ctrl+C and Ctrl+V on the keyboard.
  6. Right click -> Paste.
  7. Right click -> Cut.
  8. Right click -> Copy.
  9. Dragging and dropping text from another application.
  10. Modifying it with Javascript.
  11. Modifying it with a debug tool, like Firebug.

I'd like to display it using console.log. Is this possible in Javascript/jQuery, and if so, how do I do it?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Daniel T.
  • 37,212
  • 36
  • 139
  • 206
  • Your question as is is interesting, but you said in a comment that "What I was looking for was more a list of all the events being fired so I know which ones are available for me to hook into" - why didn't you just ask that? MSDN's doco is pretty good for this: http://msdn.microsoft.com/en-us/library/ms533051(v=VS.85).aspx - not all of the events listed are supported in all browsers, but if you check the doco for event 'on_xyz_' it will tell you "This event is defined in HTML 4.0.", or "There is no public standard that applies to this event", or whatever. – nnnnnn Sep 16 '11 at 03:56
  • 3
    **The answer** - http://stackoverflow.com/questions/7439570/how-do-you-log-all-events-fired-by-an-element-in-jquery/7439584#answer-18850523 – neaumusic Jan 14 '15 at 21:22

14 Answers14

253

I have no idea why no-one uses this... (maybe because it's only a webkit thing)

Open console:

monitorEvents(document.body); // logs all events on the body

monitorEvents(document.body, 'mouse'); // logs mouse events on the body

monitorEvents(document.body.querySelectorAll('input')); // logs all events on inputs
sidonaldson
  • 24,431
  • 10
  • 56
  • 61
  • 7
    It doesn't cover custom events but it really helps understand the event stack. – sidonaldson Sep 25 '13 at 08:19
  • This is the correct answer. You don't want to use console.log in production code, it's fine to use the console for debugging events – neaumusic Jan 14 '15 at 21:23
  • 2
    Googleing `monitorEvents` gives no relevant information on this, also, I highly suspect this is very non-standard – vsync Jan 27 '15 at 17:11
  • 5
    @vsync try "monitorEvents" in quotation marks. It's part of the console object but is browser dependant. It's only a debugging tool as it depends on console... so being standard is irrelevant – sidonaldson Jan 27 '15 at 17:19
  • 3
    Note that you can also use something like `monitorEvents($0, 'mouse');` to log all events of an *inspected* (Right click > "Inspect") element. (http://www.briangrinstead.com/blog/chrome-developer-tools-monitorevents) – rinogo Oct 19 '15 at 21:21
  • It is bad practice to add event listeners to ALL input elements. You should use document event listener with capturing flag. – WebBrother Feb 21 '18 at 10:16
  • @WebBrother monitorEvents is a web inspector only command. It's not a listener in the normal sense. Can you remove your downvote as your are incorrect :P – sidonaldson Feb 21 '18 at 12:45
  • @sidonaldson, I can not because my vote is locked now. – WebBrother Feb 21 '18 at 12:51
  • 1
    Here's the source code: https://chromium.googlesource.com/chromium/blink/+/master/Source/core/inspector/InjectedScriptSource.js#1785 – mbomb007 Sep 25 '20 at 22:03
75
$(element).on("click mousedown mouseup focus blur keydown change",function(e){
     console.log(e);
});

That will get you a lot (but not all) of the information on if an event is fired... other than manually coding it like this, I can't think of any other way to do that.

Ian Clark
  • 9,237
  • 4
  • 32
  • 49
Joseph Marikle
  • 76,418
  • 17
  • 112
  • 129
  • Odd how you and Shawn both misspelled `function`, and in the same way :). – Daniel T. Sep 16 '11 at 02:44
  • 1
    It looks like this method will bind all the native events. I'm guessing there's no way to display custom events, for example if a plugin fires some custom ones? – Daniel T. Sep 16 '11 at 02:46
  • @Daniel T. lolololol XD seems we have a little c/p going on :P – Joseph Marikle Sep 16 '11 at 02:46
  • @Daniel T. never tried it but it's possible it should work. focus is not a native event; it's one an event defined by jQuery so it's quite possible. – Joseph Marikle Sep 16 '11 at 02:47
  • 2
    I'm accepting this as the answer, but the real answer to my question is "yes and no". What I was looking for was more a list of all the events being fired so I know which ones are available for me to hook into. In this case, I can see **when** the events are being fired, but I have to know the name of it beforehand. – Daniel T. Sep 16 '11 at 03:00
  • @Daniel T. oh well then in that case: http://api.jquery.com/category/events/ and the e part of the function above will contain the information on what event fired. – Joseph Marikle Sep 16 '11 at 03:02
  • Thanks, that list helps, but it still doesn't cover custom events though. If a plugin decides to fire off a custom event, it will go unnoticed. – Daniel T. Sep 16 '11 at 03:08
  • 4
    @Joseph: regarding your earlier comment "focus is not a native event" - um...yes it is, one that's been around since long before jQuery (and before Chrome and FF, for that matter). Also, you might want to add `blur` to your list of events. – nnnnnn Sep 16 '11 at 03:42
  • @nnnnnn I thought it was onfocus that was the native event ... I'm probably wrong... I just noticed that jQuery uses events like mouseover when technically it's onmouseover. That's what I meant by that. Please correct me if I'm wrong. – Joseph Marikle Sep 16 '11 at 12:51
  • jQuery's focus is a wrapper for the native event. As for focus vs onfocus, mouseover vs onmouseover, etc., both ways are native, but the difference is in whether you use element.addEventListener("focus", handler) or element.onfocus=handler - they're not quite the same thing; see https://developer.mozilla.org/en/DOM/element.addEventListener – nnnnnn Sep 17 '11 at 00:53
  • 3
    monitorEvents(document) is the real answer – neaumusic Jan 14 '15 at 21:14
  • @neaumusic I must disagree with you. The "correct" answer in this case was apparently to manually listen for all events. That does not mean this applies to all cases. We don't know why the OP wanted the data logged to console, but this is in fact the way you would do that using javascript/jQuery. It's also very important to point out that `monitorEvents` is webkit only. It's an option, but certainly not a direct solution to the original problem. My answer above is a horrible hacked way to do it, and I would never personally use it, but it is a "real" answer. – Joseph Marikle Jan 14 '15 at 23:04
33

There is a nice generic way using the .data('events') collection:

function getEventsList($obj) {
    var ev = new Array(),
        events = $obj.data('events'),
        i;
    for(i in events) { ev.push(i); }
    return ev.join(' ');
}

$obj.on(getEventsList($obj), function(e) {
    console.log(e);
});

This logs every event that has been already bound to the element by jQuery the moment this specific event gets fired. This code was pretty damn helpful for me many times.

Btw: If you want to see every possible event being fired on an object use firebug: just right click on the DOM element in html tab and check "Log Events". Every event then gets logged to the console (this is sometimes a bit annoying because it logs every mouse movement...).

Simon
  • 7,182
  • 2
  • 26
  • 42
20
$('body').on("click mousedown mouseup focus blur keydown change mouseup click dblclick mousemove mouseover mouseout mousewheel keydown keyup keypress textInput touchstart touchmove touchend touchcancel resize scroll zoom focus blur select change submit reset",function(e){
     console.log(e);
}); 
maudulus
  • 10,627
  • 10
  • 78
  • 117
14

I know the answer has already been accepted to this, but I think there might be a slightly more reliable way where you don't necessarily have to know the name of the event beforehand. This only works for native events though as far as I know, not custom ones that have been created by plugins. I opted to omit the use of jQuery to simplify things a little.

let input = document.getElementById('inputId');

Object.getOwnPropertyNames(input)
  .filter(key => key.slice(0, 2) === 'on')
  .map(key => key.slice(2))
  .forEach(eventName => {
    input.addEventListener(eventName, event => {
      console.log(event.type);
      console.log(event);
    });
  });

I hope this helps anyone who reads this.

EDIT

So I saw another question here that was similar, so another suggestion would be to do the following:

monitorEvents(document.getElementById('inputId'));
Patrick Roberts
  • 49,224
  • 10
  • 102
  • 153
  • This is the most elegant solution of the bunch. I suppose it would be impossible to discover custom events since those could be emitted via dispatchEvent(). Yet, this covers everything else in a compact, dependency free, bit of code. – Yogi Apr 14 '18 at 18:08
12

Old thread, I know. I needed also something to monitor events and wrote this very handy (excellent) solution. You can monitor all events with this hook (in windows programming this is called a hook). This hook does not affects the operation of your software/program.

In the console log you can see something like this:

console log

Explanation of what you see:

In the console log you will see all events you select (see below "how to use") and shows the object-type, classname(s), id, <:name of function>, <:eventname>. The formatting of the objects is css-like.

When you click a button or whatever binded event, you will see it in the console log.

The code I wrote:

function setJQueryEventHandlersDebugHooks(bMonTrigger, bMonOn, bMonOff)
{
   jQuery.fn.___getHookName___ = function()    
       {
          // First, get object name
         var sName = new String( this[0].constructor ),
         i = sName.indexOf(' ');
         sName = sName.substr( i, sName.indexOf('(')-i );    

         // Classname can be more than one, add class points to all
         if( typeof this[0].className === 'string' )
         {
           var sClasses = this[0].className.split(' ');
           sClasses[0]='.'+sClasses[0];
           sClasses = sClasses.join('.');
           sName+=sClasses;
         }
         // Get id if there is one
         sName+=(this[0].id)?('#'+this[0].id):'';
         return sName;
       };

   var bTrigger        = (typeof bMonTrigger !== "undefined")?bMonTrigger:true,
       bOn             = (typeof bMonOn !== "undefined")?bMonOn:true,
       bOff            = (typeof bMonOff !== "undefined")?bMonOff:true,
       fTriggerInherited = jQuery.fn.trigger,
       fOnInherited    = jQuery.fn.on,
       fOffInherited   = jQuery.fn.off;

   if( bTrigger )
   {
    jQuery.fn.trigger = function()
    {
     console.log( this.___getHookName___()+':trigger('+arguments[0]+')' );
     return fTriggerInherited.apply(this,arguments);
    };
   }

   if( bOn )
   {
    jQuery.fn.on = function()
    {
     if( !this[0].__hooked__ ) 
     {
       this[0].__hooked__ = true; // avoids infinite loop!
       console.log( this.___getHookName___()+':on('+arguments[0]+') - binded' );
       $(this).on( arguments[0], function(e)
       {
         console.log( $(this).___getHookName___()+':'+e.type );
       });
     }
     var uResult = fOnInherited.apply(this,arguments);
     this[0].__hooked__ = false; // reset for another event
     return uResult;
    };
   }

   if( bOff )
   {
    jQuery.fn.off = function()
    {
     if( !this[0].__unhooked__ ) 
     {
       this[0].__unhooked__ = true; // avoids infinite loop!
       console.log( this.___getHookName___()+':off('+arguments[0]+') - unbinded' );
       $(this).off( arguments[0] );
     }

     var uResult = fOffInherited.apply(this,arguments);
     this[0].__unhooked__ = false; // reset for another event
     return uResult;
    };
   }
}

Examples how to use it:

Monitor all events:

setJQueryEventHandlersDebugHooks();

Monitor all triggers only:

setJQueryEventHandlersDebugHooks(true,false,false);

Monitor all ON events only:

setJQueryEventHandlersDebugHooks(false,true,false);

Monitor all OFF unbinds only:

setJQueryEventHandlersDebugHooks(false,false,true);

Remarks/Notice:

  • Use this for debugging only, turn it off when using in product final version
  • If you want to see all events, you have to call this function directly after jQuery is loaded
  • If you want to see only less events, you can call the function on the time you need it
  • If you want to auto execute it, place ( )(); around function

Hope it helps! ;-)

Codebeat
  • 6,501
  • 6
  • 57
  • 99
  • Hi @AmirFo, thanks for trying. Because you don't provide any examples what you have done, it is not possible to see if the problem is in your code or mine. Because there are others that have used this example succesfully, it is possible you did something wrong. Have you checked your code for errors? – Codebeat Apr 08 '20 at 20:32
  • There were no errors. I triggered some events, But no logs appeared in the console! I am using the latest version of chrome in ubuntu, linux. – Amir Fo Apr 09 '20 at 09:01
  • @AmirFo: Did you try it also in Firefox? What version of jQuery? – Codebeat Apr 09 '20 at 23:24
  • @AmirFo: How did you trigger the events? Did you bind any events to DOM elements before trigger it? – Codebeat Apr 10 '20 at 00:03
4

https://github.com/robertleeplummerjr/wiretap.js

new Wiretap({
  add: function() {
      //fire when an event is bound to element
  },
  before: function() {
      //fire just before an event executes, arguments are automatic
  },
  after: function() {
      //fire just after an event executes, arguments are automatic
  }
});
Robert Plummer
  • 634
  • 1
  • 5
  • 13
  • 1
    Can you give some more information about how this works and what it does exactly? How can I attach it to an element? – Josiah Oct 13 '15 at 19:09
  • This script modifies `HTMLElement.prototype.addEventListener` and probably shouldn't be used in production, but it already was great help for me for debugging purposes. – Günter Zöchbauer Dec 09 '15 at 09:23
  • 1
    This doesn't work with 1 element, it works for ALL OF THEM. It taps into the window's event handler and listens to everything that happens. It works with native event handlers, and jQuery. – Robert Plummer Jun 05 '16 at 13:22
2

STEP 1: Check the events for an HTML element on the developer console:

enter image description here

STEP 2: Listen to the events we want to capture:

$(document).on('ch-ui-container-closed ch-ui-container-opened', function(evt){
 console.log(evt);
});

Good Luck...

Aakash
  • 21,375
  • 7
  • 100
  • 81
2

I recently found and modified this snippet from an existing SO post that I have not been able to find again but I've found it very useful

// specify any elements you've attached listeners to here
const nodes = [document]

// https://developer.mozilla.org/en-US/docs/Web/Events
const logBrowserEvents = () => {
  const AllEvents = {
    AnimationEvent: ['animationend', 'animationiteration', 'animationstart'],
    AudioProcessingEvent: ['audioprocess'],
    BeforeUnloadEvent: ['beforeunload'],
    CompositionEvent: [
      'compositionend',
      'compositionstart',
      'compositionupdate',
    ],
    ClipboardEvent: ['copy', 'cut', 'paste'],
    DeviceLightEvent: ['devicelight'],
    DeviceMotionEvent: ['devicemotion'],
    DeviceOrientationEvent: ['deviceorientation'],
    DeviceProximityEvent: ['deviceproximity'],
    DragEvent: [
      'drag',
      'dragend',
      'dragenter',
      'dragleave',
      'dragover',
      'dragstart',
      'drop',
    ],
    Event: [
      'DOMContentLoaded',
      'abort',
      'afterprint',
      'beforeprint',
      'cached',
      'canplay',
      'canplaythrough',
      'change',
      'chargingchange',
      'chargingtimechange',
      'checking',
      'close',
      'dischargingtimechange',
      'downloading',
      'durationchange',
      'emptied',
      'ended',
      'error',
      'fullscreenchange',
      'fullscreenerror',
      'input',
      'invalid',
      'languagechange',
      'levelchange',
      'loadeddata',
      'loadedmetadata',
      'noupdate',
      'obsolete',
      'offline',
      'online',
      'open',
      'open',
      'orientationchange',
      'pause',
      'play',
      'playing',
      'pointerlockchange',
      'pointerlockerror',
      'ratechange',
      'readystatechange',
      'reset',
      'seeked',
      'seeking',
      'stalled',
      'submit',
      'success',
      'suspend',
      'timeupdate',
      'updateready',
      'visibilitychange',
      'volumechange',
      'waiting',
    ],
    FocusEvent: [
      'DOMFocusIn',
      'DOMFocusOut',
      'Unimplemented',
      'blur',
      'focus',
      'focusin',
      'focusout',
    ],
    GamepadEvent: ['gamepadconnected', 'gamepaddisconnected'],
    HashChangeEvent: ['hashchange'],
    KeyboardEvent: ['keydown', 'keypress', 'keyup'],
    MessageEvent: ['message'],
    MouseEvent: [
      'click',
      'contextmenu',
      'dblclick',
      'mousedown',
      'mouseenter',
      'mouseleave',
      'mousemove',
      'mouseout',
      'mouseover',
      'mouseup',
      'show',
    ],
    // https://developer.mozilla.org/en-US/docs/Web/Guide/Events/Mutation_events
    MutationNameEvent: ['DOMAttributeNameChanged', 'DOMElementNameChanged'],
    MutationEvent: [
      'DOMAttrModified',
      'DOMCharacterDataModified',
      'DOMNodeInserted',
      'DOMNodeInsertedIntoDocument',
      'DOMNodeRemoved',
      'DOMNodeRemovedFromDocument',
      'DOMSubtreeModified',
    ],
    OfflineAudioCompletionEvent: ['complete'],
    OtherEvent: ['blocked', 'complete', 'upgradeneeded', 'versionchange'],
    UIEvent: [
      'DOMActivate',
      'abort',
      'error',
      'load',
      'resize',
      'scroll',
      'select',
      'unload',
    ],
    PageTransitionEvent: ['pagehide', 'pageshow'],
    PopStateEvent: ['popstate'],
    ProgressEvent: [
      'abort',
      'error',
      'load',
      'loadend',
      'loadstart',
      'progress',
    ],
    SensorEvent: ['compassneedscalibration', 'Unimplemented', 'userproximity'],
    StorageEvent: ['storage'],
    SVGEvent: [
      'SVGAbort',
      'SVGError',
      'SVGLoad',
      'SVGResize',
      'SVGScroll',
      'SVGUnload',
    ],
    SVGZoomEvent: ['SVGZoom'],
    TimeEvent: ['beginEvent', 'endEvent', 'repeatEvent'],
    TouchEvent: [
      'touchcancel',
      'touchend',
      'touchenter',
      'touchleave',
      'touchmove',
      'touchstart',
    ],
    TransitionEvent: ['transitionend'],
    WheelEvent: ['wheel'],
  }

  const RecentlyLoggedDOMEventTypes = {}

  Object.keys(AllEvents).forEach((DOMEvent) => {
    const DOMEventTypes = AllEvents[DOMEvent]

    if (Object.prototype.hasOwnProperty.call(AllEvents, DOMEvent)) {
      DOMEventTypes.forEach((DOMEventType) => {
        const DOMEventCategory = `${DOMEvent} ${DOMEventType}`

        nodes.forEach((node) => {
          node.addEventListener(
            DOMEventType,
            (e) => {
              if (RecentlyLoggedDOMEventTypes[DOMEventCategory]) return

              RecentlyLoggedDOMEventTypes[DOMEventCategory] = true

              // NOTE: throttle continuous events
              setTimeout(() => {
                RecentlyLoggedDOMEventTypes[DOMEventCategory] = false
              }, 1000)

              const isActive = e.target === document.activeElement

              // https://developer.mozilla.org/en-US/docs/Web/API/DocumentOrShadowRoot/activeElement
              const hasActiveElement = document.activeElement !== document.body

              const msg = [
                DOMEventCategory,
                'target:',
                e.target,
                ...(hasActiveElement
                  ? ['active:', document.activeElement]
                  : []),
              ]

              if (isActive) {
                console.info(...msg)
              }
            },
            true,
          )
        })
      })
    }
  })
}
logBrowserEvents()
// export default logBrowserEvents
random-forest-cat
  • 33,652
  • 11
  • 120
  • 99
2
function bindAllEvents (el) {
  for (const key in el) {
      if (key.slice(0, 2) === 'on') {
          el.addEventListener(key.slice(2), e => console.log(e.type));
      }
  }
}
bindAllEvents($('.yourElement'))

This uses a bit of ES6 for prettiness, but can easily be translated for legacy browsers as well. In the function attached to the event listeners, it's currently just logging out what kind of event occurred but this is where you could print out additional information, or using a switch case on the e.type, you could only print information on specific events

Lisa
  • 21
  • 1
2

Just add this to the page and no other worries, will handle rest for you:

$('input').live('click mousedown mouseup focus keydown change blur', function(e) {
     console.log(e);
});

You can also use console.log('Input event:' + e.type) to make it easier.

Shawn Khameneh
  • 472
  • 4
  • 16
1

Here is a non-jquery way to monitor events in the console with your code and without the use of monitorEvents() because that only works in Chrome Developer Console. You can also choose to not monitor certain events by editing the no_watch array.

    function getEvents(obj) {
    window["events_list"] = [];
    var no_watch = ['mouse', 'pointer']; // Array of event types not to watch
    var no_watch_reg = new RegExp(no_watch.join("|"));

    for (var prop in obj) {
        if (prop.indexOf("on") === 0) {
            prop = prop.substring(2); // remove "on" from beginning
            if (!prop.match(no_watch_reg)) {
                window["events_list"].push(prop);
                window.addEventListener(prop, function() {
                    console.log(this.event); // Display fired event in console
                } , false);
            }
        }
    }
    window["events_list"].sort(); // Alphabetical order 

}

getEvents(document); // Put window, document or any html element here
console.log(events_list); // List every event on element
Jeff Baker
  • 1,492
  • 1
  • 12
  • 15
1

How to listen for all events on an Element (Vanilla JS)


For all native events, we can retrieve a list of supported events by iterating over the target.onevent properties and installing our listener for all of them.

for (const key in target) {
    if(/^on/.test(key)) {
        const eventType = key.substr(2);
        target.addEventListener(eventType, listener);
    }
}

The only other way that events are emitted which I know of is via EventTarget.dispatchEvent, which every Node and thefore every Element inherits.
To listen for all these manually triggered events, we can proxy the dispatchEvent method globally and install our listener just-in-time for the event whose name we just saw ✨ ^^

const dispatchEvent_original = EventTarget.prototype.dispatchEvent;
EventTarget.prototype.dispatchEvent = function (event) {
    if (!alreadyListenedEventTypes.has(event.type)) {
        target.addEventListener(event.type, listener, ...otherArguments);
        alreadyListenedEventTypes.add(event.type);
    }
    dispatchEvent_original.apply(this, arguments);
};

function snippet

function addEventListenerAll(target, listener, ...otherArguments) {

    // install listeners for all natively triggered events
    for (const key in target) {
        if (/^on/.test(key)) {
            const eventType = key.substr(2);
            target.addEventListener(eventType, listener, ...otherArguments);
        }
    }

    // dynamically install listeners for all manually triggered events, just-in-time before they're dispatched ;D
    const dispatchEvent_original = EventTarget.prototype.dispatchEvent;
    function dispatchEvent(event) {
        target.addEventListener(event.type, listener, ...otherArguments);  // multiple identical listeners are automatically discarded
        dispatchEvent_original.apply(this, arguments);
    }
    EventTarget.prototype.dispatchEvent = dispatchEvent;
    if (EventTarget.prototype.dispatchEvent !== dispatchEvent) throw new Error(`Browser is smarter than you think!`);

}


// usage example
const input = document.querySelector('input');
addEventListenerAll(input, (evt) => {
    console.log(evt.type);
});
input.focus();
input.click();
input.dispatchEvent(new Event('omg!', { bubbles: true }));


// usage example with `useCapture`
// (also receives `bubbles: false` events, but in reverse order)
addEventListenerAll(
    input,
    (evt) => { console.log(evt.type); },
    true
);
document.body.dispatchEvent(new Event('omfggg!', { bubbles: false }));
pitizzzle
  • 303
  • 3
  • 8
0

I needed to solve this so made this little jQuery plugin that decorates the original jQuery.prototype.on method and logs the important information. This only logs click, change & input events, but you can allow more events using the ACCEPTED_EVENT_TYPES Array. All events are intercepted.

Just include it at the top of your code before you start binding

$('.whatever').on(...stuff);

Chrome dev tools console log

!(function() {
  const ACCEPTED_EVENT_TYPES = ['click', 'change', 'input'];
  const originalFn = $.fn.on;

  /** styles **/
  const magenta = 'color: #a939d5;';
  const cyan = 'color: #17a2b8;';
  const reset = '';

  function handleArguments(type, child, callback) {
    function jQueryEventDebugCallback(e, ...callbackArgs) {
      if (ACCEPTED_EVENT_TYPES.includes(e.type)) {
        const target = e.delegateTarget;
        const selector = target.id ? '#' + target.id : [...target.classList].map(x => `.${x}`).join(' ');
        const title = 'color:white;background:#0769ad;font-weight:bold;'
        console.groupCollapsed(
          `%c jQuery event called: %c $('%c%s%c').on('%c%s%c', '${child}', ${callback.name || 'anonymous'})`,
          title,
          reset,
          magenta,
          selector,
          reset,
          cyan,
          type,
          reset,
        );
        console.log({
          e,
          'this': this,
          type, child,
          callback,
          isDefaultPrevented: e.isDefaultPrevented(),
        });
        console.groupEnd();
      }
      return callback.apply(this, [e, ...callbackArgs]);
    }
    return originalFn.call(this, type, child, jQueryEventDebugCallback);
  }

  $.fn.on = function jQueryEventDebug(...args) {
    if (args.length === 2)  {
      return handleArguments.call(this, args[0], null, args[1]);
    }
    return handleArguments.apply(this, args);
  }
})();
synthet1c
  • 6,152
  • 2
  • 24
  • 39