Skip to content

Instantly share code, notes, and snippets.

@reatlat
Forked from PaulKinlan/monitorEvents.js
Created April 13, 2021 21:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save reatlat/c7c7ec6be8c6bbcb13b703c2023f855d to your computer and use it in GitHub Desktop.
Save reatlat/c7c7ec6be8c6bbcb13b703c2023f855d to your computer and use it in GitHub Desktop.
monitorEvents.js
function monitorEvents(element) {
var log = function(e) { console.log(e);};
var events = [];
for(var i in element) {
if(i.startsWith("on")) events.push(i.substr(2));
}
events.forEach(function(eventName) {
element.addEventListener(eventName, log);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment