-
-
Save MohamedAlaa/31c5bc3f47fda69765f4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This is a simple function to get all the attached jquery events on all the DOM elements | |
// you will find a new data attribute on the elements that has events attached to it. | |
(function() { | |
if (window.jQuery) { | |
var elms = [], | |
elm = {}, | |
attrs = "", | |
evTypes = 0, | |
evCounter = 0, | |
elmCounter = 0, | |
attrName = "data-attached-events"; | |
jQuery.each($("*"), function() { | |
elmCounter++; | |
elm = this; | |
evt = jQuery._data(elm, "events"); | |
if (evt) { | |
elms.push(elm); | |
evTypes++; | |
attrs = "" | |
jQuery.each(evt, function(ky, vl) { | |
evCounter++; | |
attrs += ky + "-" + vl.length + " "; | |
}); | |
jQuery(elm).attr(attrName, attrs); | |
} | |
}); | |
console.clear(); | |
console.info("There are " + evTypes + " diffrent types of events as a total of " + evCounter + " event, are attached to " + elmCounter + " elements."); | |
console.info("You will find a new attribute called '" + attrName + "' over the dom elements that have a jquery event attached" + '\n'); | |
console.groupCollapsed(); | |
jQuery.each(elms, function() { | |
console.log(this); | |
}); | |
console.groupEnd(); | |
return "▲ open group to see elements"; | |
} else { | |
console.error("Ops, jQuery not detected"); | |
} | |
return "Done!"; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment