[英]Finding the Javascript file and line number that causes some action using Firebug or some other tool
Is it possible to use Firebug ( or some other tool ) to find out where some JS action came from ... ie which file and line. 是否可以使用Firebug(或其他工具)来找出一些JS动作来自哪里......即哪个文件和行。
For instance I have a button that causes a dropdown/slide and I want to find the Javascript that affected that drop down. 例如,我有一个按钮,导致下拉/滑动,我想找到影响该下拉列表的Javascript。 I know I can probably find it by doing a lot of detective work;
我知道我可以通过做很多侦探工作来找到它; but if it was CSS I was looking for then all I would have to do is to look in Firebug and it would give me the file and line number.
但如果是我正在寻找的CSS那么我要做的就是查看Firebug,它会给我文件和行号。 Is there any way of getting something similar for Javascript?
有没有办法为Javascript获得类似的东西?
Using the firequery plugin for firefox you might be able to find some information about what events are attached to certain elements. 使用firefox的firequery插件,您可能能够找到有关哪些事件附加到某些元素的信息。
Other than this your best way to approach the problem would be using console logs to pinpoint which element is firing the event. 除此之外,解决问题的最佳方法是使用控制台日志来确定触发事件的元素。 Maybe by searching for class names or id's on that element would be a good place to start.
也许通过在该元素上搜索类名或id是一个很好的起点。
In Chrome's Developer Tool, on the Elements tab, you'll see a column on the right with information about the selected element. 在Chrome的开发者工具中,在“元素”标签上,您会在右侧看到一列,其中包含有关所选元素的信息。 One of the panels is called Event Listeners which shows the events bound to an element and the source location.
其中一个面板称为事件监听器,它显示绑定到元素和源位置的事件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.