且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在Chrome开发工具中使用getEventListeners?

更新时间:2023-09-30 10:23:16


  1. 打开DevTools

  2. 打开元素选项卡并找到元素(.someclass)

  3. 每个元素有四个选项卡 - 样式,属性,DOM断点和事件侦听器

  4. 选择事件监听器


I tried to trace back which function hooked into a click event of .someclass. I open Chrome Dev Tool and type this

getEventListeners(document.querySelector('.someclass'));

The result is this

Object {}

I cannot click and open it to find out the name of the object or the source code that handle click event.

Is there a way to find out?

UPDATE 1:

Followed Krasimir's advise below. There could be only two events: mousemove or mouseover. So how do I find out the exact function handling that event for canvas.overlay? There are just too many to drill down into.

  1. Open the DevTools
  2. Open the Elements tab and locate your element (.someclass)
  3. There are four tabs per element - Styles, Properties, DOM Breakpoints and Event Listeners
  4. Select Event Listeners