Where's the JS coming from?
Chrome's Dev Tools are excellent, and list the Event Listeners bound to a DOM element.
In this example I could see a click event had been bound to a link (OK, not that hard to know as I wanted to change it's click behaviour). The problem is jQuery is handling this click event so Chrome just lists jQuery as the source.
Right clicking on the handler 'function' to 'Show Function Definition' doesn't get us anywhere either. It should go directly to the code, which it does; it shows a line of code in jQuery… not too helpful.
At least give me a clue
With a bit of Googling I found the answer but it's tricky to know what to search on (I tried naming this post multiple times). Unsurprisingly it's in a Google forum, and Paul Irish is involved.
The full thread here. https://groups.google.com/d/msg/google-chrome-developer-tools/NTcIS15uigA/BU0nB78hK9AJ
A feature of Dev Tools Console is $0. It's a reference to the last element clicked on in the Elements DOM view. $1, is the 2nd last element clicked on etc. A history of clicks. With 3 bits of the puzzle; element, _data and 'Show Function Definition' we can view the source.
Output this to the console, fold open 'events', then 'click' and the raw code can be seen against 'handler'. It's short and simple in this case, but where's the code loaded from? Right-click and 'Show Function Definition'.
There it is in file, 'index.php', line 219.
This code might have been pieced together via template partials in a CMS but it's a simple site-wide search to find it.