Find out which Javascript function is fired on click
In Google Chrome, open your web page of interest.
Right-click on the element(i.e a button) you want to inspect. In the 'context menu' that appears, click 'Inspect'. A 'Developer tools' window will appear.
- Click the 'Elements' tab.
- Click the HTML element you wish to inspect if not already selected.
- Click on the 'Event Listeners' tab. A full list of listeners will show up.
- Select the event listener you're interested in. i.e 'click'. A call stack will show up.
- Click on the last item in the call stack. This will finally redirect you to that actual function that gets executed when the event fires.
Use Chrome's Web Inspector to inspect the element and check out the Event Listeners panel.
If the code attaching the event is in a library (for example, by Zepto in my example), set a breakpoint on the line and examine the call stack to see where it originated in your code.
As you can see, the event has originated in my code and now I know the filename and line number.