view event handlers in Chrome

Chrome developer tools can be used to view event handlers/listeners on any element in an html page. This is pretty handy to quickly view event handlers on a site without going into its javascript or html code. Here are the quick steps to achieve this:

  1. We’ll use the following html code for the purpose of this article:
    <!doctype html>
    <title>Chrome developer tools - view event listeners example</title>
    <h1>Chrome developer tools - view event listeners example</h1>
    <a href="" onclick="alert('foo'); return false;">clickme</a>
    You can see the live example html page at Chrome developer tools – view event listeners example.
  2. First right click on the element you want to see event listeners for. Here we’ll right click on link “clickme”. Then click on inspect element as shown below:
  3. This will open up chrome developer tools. Make sure element tab is selected.
  4. In the right panel click on even listeners. Click on click event and then click on node “a”. To view the javascript code, you can mouseover the listenerBody function snippet as shown below:
Share this article: share on Google+ share on facebook share on linkedin tweet this submit to reddit


Click here to write/view comments