如何找到jQuery事件的原始(匿名函数)源? [英] How to find the original (Anonymous function) source of jQuery events?

查看:109
本文介绍了如何找到jQuery事件的原始(匿名函数)源?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大多数jQuery代码使用匿名函数,例如:

Most jQuery code uses anonymous functions, such as:

jQuery('someelements').someEvent(function() {
    // code here
});

这很有效,但调试效果不佳。我尝试使用Firefox Firebug和Chrome的检查器找到一些匿名函数的来源,具有暂停javascript功能,但它调用的实际代码是在jQuery js文件中,并且单步执行代码从不告诉什么行,甚至是什么.js文件添加了该事件。如何查看操作的定义?

This works well, but doesn't do so well for debugging. I tried to find the source of some anonymous functions using both Firefox Firebug and Chrome's inspector, with the pause javascript functionality, but the actual code it calls is in the jQuery js file, and stepping through the code never tells what line, or even what .js file added that event. How can I see where the action is defined?

推荐答案

尝试使用 jQuery的非缩小版本并使用Firebug中的 profile 功能查找jQuery源中与代码中事件发生时调用的确切行。

Try using the non-minified version of jQuery and using the profile functionality in Firebug to find the exact line in the jQuery source that is being called on the occurance of an event in your code.

如果您的目的是找到一些jQuery选择器或函数实现的实现,请参考这个令人惊奇的资源,它确实如此:

http://www.keyframesandcode.com/resources/javascript/deconstructed/jquery/

If your intention is to find the implementation of some jQuery selectors or functions implementation, please refer this amazing resource that does exactly that:
http://www.keyframesandcode.com/resources/javascript/deconstructed/jquery/

这篇关于如何找到jQuery事件的原始(匿名函数)源?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆