Determine what Javascript function is called when you click an element

11,088

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

Share:
11,088
Nicu Surdu
Author by

Nicu Surdu

I'm a creative person, which finds pleasure in solving interesting problems and enjoys using his free time to write cool apps for awesome people, build and play with gadgets.

Updated on August 04, 2022

Comments

  • Nicu Surdu
    Nicu Surdu over 1 year

    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.

  • Talik
    Talik over 3 years
    if you cant see the listeners, press Esc on Chrome or click the 3 dot menu and "open console drawer"