I donβt know why it took me so long to understand, but you can directly print the onclick handler:
<html> <head> <script> function thisiswhyimhot() { alert("this is why you're not"); } function mybodyisready() { alert(document.getElementById("hottestdivever").onclick); } </script> </head> <body onload="mybodyisready()"> <div id="hottestdivever" onclick="thisiswhyimhot()"></div> </body> </html>
A warning appears with the following:
function onclick(event) { thisiswhyimhot() }
If the handler was installed using jQuery, it is stored in a slightly different way:
alert(jQuery._data(document.getElementById("hottestdivever"), "events").click[0].handler);
This will give you something to search in your JS.
And finally, JSFiddle demonstrates vanilla Javascript and jQuery methods.
In other news, I have a new function name for each onload body, from which I write now until the end of time ...
source share