我在 JQuery 文档就绪方法中有一些函数,我想从其他外部文件引用它们,但我总是得到一个未定义的函数。我怎样才能使它们全局化?
例如。
external file 1
$(function ()
{
function DoSomething()
{
Do something
}
});
external file 2
$(function ()
{
Call DoSomething()
)};
最佳答案
在 jQuery escope 之外声明函数。
external file 1
function DoSomething()
{
Do something
}
external file 2
$(function ()
{
Call DoSomething()
)};
关于javascript - 如何在文档准备好的情况下引用函数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7352264/