Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Determine what Javascript function is called when you click an element

Is there a way to determine what Javascript function is called when you click on an item in a HTML page that has JS binded to the click event (added using jQuery, not the onClick tag attribute) ?

Obviously, the website is not mine and the code is minified.

like image 911
Nicu Surdu Avatar asked May 18 '12 08:05

Nicu Surdu


1 Answers

This is available in all major browsers in the developer tools (usually press F12 to open).

In Chrome, for example, right click on the element, inspect element.

Then expand the 'Event Listeners' tab on the righthand side, find 'click' and expand that. It should give you a list of all potential listeners on the click event, including ones that would catch from bubbling up and a link to the function and its position in the file.

It can admittedly take a bit of hunting. If the code is minified most developer tools can expand it for you (e.g. the 'pretty print' option in webkit browsers like Chrome or tools 'Format javascript' in IE) or use an external tool, e.g. http://jsbeautifier.org/.

enter image description here

like image 138
mattmanser Avatar answered Nov 09 '22 03:11

mattmanser