If an event handler is hung via javascript using addEventListener, then you can easily catch an event handler through Chrome Developer Tools, for example. But in the case of connecting the handler through the $ (element) .bind () method, Chrome Developer Tools shows the first line of the jquery.min.js file. How to look directly at the function that calls the bind method on this element?

  • Is it possible a little more? Where to set breakpoint and how? - Lucky
  • It turned out to solve the problem? I would also like to figure out how to get into the handler function, not knowing where it is located. The option to look at the "onClick" attribute in properties is clearly not suitable. - Oleg Grigoriev

3 answers 3

In chrome: hover the element - from the context menu "View element code" (or F12, Elements tab, find the desired element) - in the right part, see the Properties sub-item, open the first sub-item in this part and see the attribute value (for example, onclick) , there is either null (not assigned), or just function () (it means, somewhere in the code the handler is set, press the right button, there is one show function definition, throws on the declaration of this function), the code in the attribute of the element can be seen by element.

    And what's the problem to put breakpoint on the handler?

    Is it possible a little more? Where to set breakpoint and how?

    In chrome, in the web inspector, go to the Sources tab, and under the Elements tab there is a button with an arrow; by clicking on it you can select the file where the script is located. Next, just click on the line number where you need to set breakpoint. A blue pointer appears. Everything! Now the script will stop at this place.

    alt text

    • one
      You do not understand me. The fact is that I don’t even know the name of the file from which the handler is called. - Lucky

    Purely for debugging, download jquery not min - http://code.jquery.com/jquery-1.8.1.js - in this case you will see the necessary line.

    • Not. I do not need to see jquery.js in any way. I need to see the function calling the event handler through the jQuery API. - Lucky