简体   繁体   English

如何使用firebug调试javascript和jquery

[英]How to Debug javascript and jquery with firebug

I just installed firebug and want to see and debug jquery and javascript methods when fired. 我刚刚安装了firebug,并希望在触发时查看和调试jquery和javascript方法。

Suppose that a jquery function will be called when button is clicked. 假设在单击按钮时将调用jquery函数。 When the site is huge and the page includes many js files then it is very difficult to point out which function will be called and where it is defined, because people attach button events in a different way. 当站点很大并且页面包含许多js文件时,很难指出将调用哪个函数以及它被定义的位置,因为人们以不同的方式附加按钮事件。 I mean the event is attached sometime based on css. 我的意思是该事件基于css在某个时候被附加。 So sometimes I just cannot find out which method is going to be invoked. 所以有时我只是无法找出将要调用的方法。

So please give me some tips so that I can see those functions invoke and the function body at run time wherever it is defined. 所以请给我一些提示,以便我可以在运行时查看这些函数调用和函数体,无论它在何处定义。 Thanks. 谢谢。

You can try using FireQuery . 您可以尝试使用FireQuery From the site: 从网站:

  • jQuery expressions are intelligently presented in Firebug Console and DOM inspector 在Firebug Console和DOM检查器中智能地呈现jQuery表达式
  • attached jQuery data are first class citizens 附加的jQuery数据是一等公民
  • elements in jQuery collections are highlighted on hover jover集合中的元素在悬停时突出显示
  • jQuerify: enables you to inject jQuery into any web page jQuerify:使您能够将jQuery注入任何网页
  • jQuery Lint: enables you to automatically inject jQuery Lint into the page as it is loaded (great for ad-hoc code validation) jQuery Lint:使您能够在加载时自动将jQuery Lint注入页面(非常适合特殊代码验证)

I've used it a few times and it makes debugging (when using jQuery) much easier. 我已经使用了几次,它使得调试(使用jQuery时)变得更加容易。

EDIT 编辑

Using the plugin, you can look at the element and see the events bound to it. 使用该插件,您可以查看元素并查看绑定到它的事件。 Your other option is to search your codebase for anything that identifies the element (id or css class perhaps). 您的另一个选择是在代码库中搜索标识元素的任何内容(可能是id或css类)。 Then you should also be able to see what gets bound. 那么你也应该能够看到被束缚的东西。

Take a look at http://firequery.binaryage.com/ (FireQuery). 看看http://firequery.binaryage.com/(FireQuery )。 It's an extension to FireBug that allows you to see jQuery calls. 它是FireBug的扩展,允许您查看jQuery调用。 I haven't used it that much, but it might be what you're looking for. 我没有那么多使用它,但它可能是你正在寻找的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM