使用 Firebug 调试 jQuery

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/721809/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 09:38:23  来源:igfitidea点击:

Debugging jQuery with Firebug

jquery

提问by PositiveGuy

I've seen a ton of old posts out there on how to try to debug jQuery in Firebug. Anyone have a good way yet cause I do not see one at all that works.

我已经看到大量关于如何尝试在 Firebug 中调试 jQuery 的旧帖子。任何人都有一个好方法,因为我根本看不到一个有效的方法。

回答by Colleen Kitchen

I think the asker really just wants to know how to use the tool at a very basic level, and I guess none of these answers target their issue straight on that's why they don't get green check. though the info in them is useful once you get past the basics. This Q is old and the original author has probably gone on to make a million bucks, but perhaps this answer will benefit someone else. I don't know much myself but here is what I do know.

我认为提问者真的只是想知道如何在非常基本的层面上使用该工具,我想这些答案都没有直接针对他们的问题,这就是为什么他们没有得到绿色支票。尽管一旦您掌握了基础知识,其中的信息就会很有用。这个 Q 很旧,原作者可能已经赚了 100 万美元,但也许这个答案会让其他人受益。我自己知道的不多,但这是我所知道的。

You use the scripts tab from the firebug window. Look at the top you see console, html, css, scriptDOMetc. tabs. You want to select the scripttag then below that in impossibly small type there's another row of tabs the first one defaults to static and the second one is a drop down of all the components that have javascript. Select the one you want to debug and go to the left of it and click in the margin beside the line you want to set a break point. A red circle still appears there. Now over the right there are arrows for step into, step over, etc. and to the right of that under watch you can watch variables go by.

您可以使用萤火虫窗口中的脚本选项卡。看看顶部,您会看到consolehtmlcssscript DOM等选项卡。您想选择脚本标签,然后在不可能的小类型下面有另一行选项卡,第一个默认为静态,第二个是所有具有 javascript 的组件的下拉列表。选择您要调试的那个,然后转到它的左侧,然后单击要设置断点的行旁边的空白处。那里仍然出现一个红色圆圈。现在在右侧有用于进入、跨过等的箭头,在 watch 的右侧,您可以观察变量的经过。

回答by tvanfosson

First, make sure that you're not using the minimized or packed version of jQuery. That would be virtually impossible to debug. Next, I find that it helps to step through at least once so that you know where to set breakpoints in the jQuery code. You may also want to break the chaining of any jQuery statements in your code and assign the intermediate results to variables that you can inspect. Other than that, I'm with @Chad. I haven't had a lot of problems debugging my jQuery-based code.

首先,确保您没有使用 jQuery 的最小化或打包版本。这几乎不可能调试。接下来,我发现至少单步执行一次会有所帮助,以便您知道在 jQuery 代码中设置断点的位置。您可能还想打破代码中任何 jQuery 语句的链接,并将中间结果分配给您可以检查的变量。除此之外,我和@Chad 在一起。我在调试基于 jQuery 的代码时没有遇到很多问题。

回答by rg88

Try this plugin. It is specifically for debugging jquery based javascript in Firebug. Lets you drop into chained events and log them to console.

试试这个插件。它专门用于在 Firebug 中调试基于 jquery 的 javascript。让您进入链式事件并将它们记录到控制台。

回答by bsberry

You will likely also want to double-check most of your code with the jQuery documentation. jQuery code looks seductively familiar, but has some very odd programming paradigms that produce what is effectively noise when not accounted for.

您可能还想使用jQuery 文档仔细检查您的大部分代码。jQuery 代码看起来很熟悉,但有一些非常奇怪的编程范式,如果不加以考虑,就会产生有效的噪音。