编程语言
首页 > 编程语言> > 有没有办法告诉哪个JavaScript文件包含事件处理程序?

有没有办法告诉哪个JavaScript文件包含事件处理程序?

作者:互联网

这个问题困扰了我一段时间,我确定有某种技术可以阻止这种情况的发生,但是有没有办法找到哪个Javascript文件链接到按钮?

因此,当我按下一个提交按钮并触发一个Javascript事件时,我需要找到被触发的代码,而不是在html头中的每个链接中进行拖网尝试来查找

"jQuery('submitBtn').click(..."

我正在使用Firebug,有时还使用Chrome的控制台.

解决方法:

您可以使用Visual Event 2告诉您源文件和行号(我认为它适用于chrome)

Visual Event is an open source Javascript bookmarklet which provides
debugging information about events that have been attached to DOM
elements. Visual Event shows:

  • Which elements have events attached to them
  • The type of events
    attached to an element
  • The code that will be run with the event is
    triggered
  • The source file and line number for where the attached
    function was defined (Webkit browsers and Opera only)

标签:firebug,javascript
来源: https://codeday.me/bug/20191201/2083070.html