在jQuery文档中调用函数准备就绪 [英] Calling function inside jQuery document ready

查看:288
本文介绍了在jQuery文档中调用函数准备就绪的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在调试时,我总是使用Firebug并尝试调用函数并显示变量。但是我不能在 $(文件).ready 中定义函数或变量。

While debugging, I always use Firebug and try to call functions and show variables. However I can't when the function or variable is defined within $(document).ready.

怎么能我访问这些变量?我可以输入类似命名空间的内容,例如 document.ready.variableName 或者我怎么能看到这个?

How can I access these variables? Can I type something like a namespace, like document.ready.variableName or how can I see this?

谢谢提前完成。

推荐答案

可以通过将它们指定为窗口的属性来创建全局变量和函数

Global variables and functions can be created by assigning them as a property of window:

$(function(){
    window.foo = function foo() {
        // …
    }
});

foo()应该可以在任何地方访问该处理程序已执行。

foo() should be accessible anywhere after that handler is executed.

这篇关于在jQuery文档中调用函数准备就绪的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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