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

查看:25
本文介绍了如何找到 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天全站免登陆